Exemple #1
0
        public IActionResult Create(ProcessViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (model.SchoolUuid == null && AuthContextService.CurrentUser.SchoolGuid == null)
            {
                response.SetFailed("请登录学校账号");
                return(Ok(response));
            }
            using (_dbContext)
            {
                //if (_dbContext.MealFlow.Any(x => x.CuisineUuid == model.CuisineUuid && x.MealType == model.MealType && x.AddTime == Convert.ToDateTime(model.AddTime).ToString("yyyy-MM-dd")))
                //{
                //    response.SetFailed("当天该用餐类型的菜品已存在");
                //    return Ok(response);
                //}
                var mealFlow = new MealFlow()
                {
                    MealFlowUuid  = Guid.NewGuid(),
                    CuisineUuid   = model.CuisineUuid,
                    MealType      = model.MealType,
                    Buying        = model.Buying,
                    Detection     = model.Detection,
                    WashVege      = model.WashVege,
                    Chopper       = model.Chopper,
                    Cook          = model.Cook,
                    BuyingTime    = model.BuyingTime,
                    DetectionTime = model.DetectionTime,
                    WashVegeTime  = model.WashVegeTime,
                    ChopperTime   = model.ChopperTime,
                    CookTime      = model.CookTime,
                    //BuyingTime = Convert.ToDateTime(model.BuyingTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    //DetectionTime = Convert.ToDateTime(model.DetectionTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    //WashVegeTime = Convert.ToDateTime(model.WashVegeTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    //ChopperTime = Convert.ToDateTime(model.ChopperTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    //CookTime = Convert.ToDateTime(model.CookTime).ToString("yyyy-MM-dd HH:mm:ss"),
                    //AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    AddTime    = Convert.ToDateTime(model.AddTime).ToString("yyyy-MM-dd"),
                    IsDelete   = 0,
                    SchoolUuid = model.SchoolUuid != null ? model.SchoolUuid : AuthContextService.CurrentUser.SchoolGuid,
                };
                _dbContext.MealFlow.Add(mealFlow);
                var num = _dbContext.SaveChanges();
                if (num > 0)
                {
                    response.SetSuccess("添加成功");
                }
                else
                {
                    response.SetFailed("添加失败");
                }

                return(Ok(response));
            }
        }
Exemple #2
0
        /// <summary>
        /// 已完成状态
        /// </summary>
        /// <param name="x"></param>
        /// <param name="list2"></param>
        /// <returns></returns>
        private static string State(MealFlow x, System.Collections.Generic.List <SystemUser> list2)
        {
            var s = "";
            var u = "";

            if (!string.IsNullOrEmpty(x.BuyingTime))
            {
                s = "买入:";
                u = x.Buying;
            }
            if (!string.IsNullOrEmpty(x.DetectionTime))
            {
                s = "检测:";
                u = x.Detection;
            }
            if (!string.IsNullOrEmpty(x.WashVegeTime))
            {
                s = "洗菜:";
                u = x.WashVege;
            }
            if (!string.IsNullOrEmpty(x.ChopperTime))
            {
                s = "切配:";
                u = x.Chopper;
            }
            if (!string.IsNullOrEmpty(x.CookTime))
            {
                s = "成菜:";
                u = x.Cook;
            }
            if (!string.IsNullOrEmpty(u))
            {
                var arr  = u.Split(',');
                var list = list2.Where(x => arr.Contains(x.SystemUserUuid.ToString())).Select(x => x.RealName).ToList();
                u = string.Join(',', list);
            }
            s += u;
            return(s);
        }