BistroDriveWebApp.Models.DishRepository.AddDishReview C# (CSharp) Method

AddDishReview() public method

public AddDishReview ( string owner, int dish_id, int mark, string text ) : void
owner string
dish_id int
mark int
text string
return void
        public void AddDishReview(string owner, int dish_id, int mark, string text)
        {
            dishreview dr = new dishreview
            {
                Id_Owner = owner,
                Id_Dish = dish_id,
                Mark = (int)mark,
                Description = text
            };
            context.dishreviews.Add(dr);
            context.SaveChanges();
            double average = (double)context.dishreviews.Where(r=>r.Id_Dish == dish_id).Average(r => r.Mark);
            dish d = GetDishById(dish_id);
            d.Raiting = Convert.ToInt32(Math.Round(average, 0));
            context.SaveChanges();
        }