コード例 #1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> AddAsync(MealMenuModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.InsertAsync <string, MealMenuModel>(model);

                return(!string.IsNullOrWhiteSpace(result));
            }
        }
コード例 #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> UpdateAsync(MealMenuModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.UpdateAsync(model);

                return(result > 0);
            }
        }
コード例 #3
0
        public async Task <IActionResult> AddDisheMaintenanceAsync([FromBody] AddDisheMaintenanceAsyncRequestDto request)
        {
            if (string.IsNullOrWhiteSpace(request.HospitalGuid))
            {
                var userModel = await new MealOperatorBiz().GetModelAsync(UserID);
                if (userModel == null)
                {
                    return(Failed(ErrorCode.DataBaseError, "无法获取医院所在信息!"));
                }
                request.HospitalGuid = userModel.HospitalGuid;
            }
            List <MealMenuModel> newMealMenuModelList = new List <MealMenuModel>();

            if (request.DishesGuidArr == null || !request.DishesGuidArr.Any() || string.IsNullOrWhiteSpace(request.DishesGuidArr[0]))
            {
                //return Failed(ErrorCode.Empty, "菜品项为空,请选择菜项!");
            }
            else
            {
                var dishesModelList = await new MealDishesBiz().GetModelsByIdArrAndHospitalGuidAsync(request.DishesGuidArr, request.HospitalGuid);
                if (dishesModelList == null || !dishesModelList.Any())
                {
                    return(Failed(ErrorCode.Empty, "传入菜品项Guid有误,请检查!"));
                }
                foreach (var item in dishesModelList)
                {
                    var model = new MealMenuModel()
                    {
                        MenuGuid        = Guid.NewGuid().ToString("N"),
                        HospitalGuid    = request.HospitalGuid,
                        CategoryGuid    = request.CategoryGuid,
                        DishesGuid      = item.DishesGuid,
                        MenuDate        = request.Date.Value,
                        Enable          = true,
                        CreatedBy       = UserID,
                        LastUpdatedBy   = UserID,
                        CreationDate    = DateTime.Now,
                        LastUpdatedDate = DateTime.Now,
                        OrgGuid         = "G"
                    };
                    newMealMenuModelList.Add(model);
                }
            }
            var oldMealMenuModeList = await new MealMenuBiz().GetModelListByCondition(request.CategoryGuid, request.HospitalGuid, request.Date);
            var response            = await new MealMenuBiz().AddDisheMaintenanceAsync(newMealMenuModelList, oldMealMenuModeList);

            if (!response)
            {
                return(Failed(ErrorCode.Empty, "添加菜品失败,请联系管理员!"));
            }
            return(Success());
        }