示例#1
0
        /// <summary>
        /// Обновляет пользовательский заказ по id недельного заказа используя значения
        ///Id дневных заказов и массив значений количеств заказанных блюд
        /// </summary>
        /// <param name="context"></param>
        /// <param name="userWeekOrderDto"></param>
        /// <returns></returns>
        public static void UpdateAllQuantitiesOnWeekOrder(this ApplicationDbContext context,
                                                          UpdateAllWeekOrderDto userWeekOrderDto)
        {
            var dayorderarrayidParameter = new SqlParameter("@DayOrderIdArray",
                                                            MapHelper.CreateDataTable(userWeekOrderDto.DayOrdIds, "dayord"))
            {
                TypeName  = "dbo.DayOrdArray",
                SqlDbType = SqlDbType.Structured
            };
            var weekordidParameter  = new SqlParameter("@weekordid", userWeekOrderDto.WeekOrdId);
            var quantitiesParameter = new SqlParameter("@quantities", MapHelper.CreateDataTable(userWeekOrderDto.QuantArray, "quant"))
            {
                TypeName  = "dbo.QuantArray",
                SqlDbType = SqlDbType.Structured
            };

            try
            {
                context.Database.ExecuteSqlCommand(
                    "exec UpdateAllQuantitiesOnWeekOrder @DayOrderIdArray, @weekordid, @quantities", dayorderarrayidParameter, weekordidParameter, quantitiesParameter);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public async Task <IHttpActionResult> UpdateAll([FromBody] UpdateAllWeekOrderDto uaDto)
        {
            _unitOfWork.GetContext().UpdateAllQuantitiesOnWeekOrder(uaDto);

            return(Ok(true));
        }