コード例 #1
0
 public JsonResult Delete(MealMenuView mealMenu)
 {
     mealMenu.ModifiedBy         = CurrentUser.Name;
     mealMenu.ModifiedByFullName = CurrentUser.FullName;
     return(Json(MealMenuService.Delete(new MealMenuDeleteRequest {
         MealMenu = mealMenu
     }), JsonRequestBehavior.DenyGet));
 }
コード例 #2
0
        public void Delete(MealMenuView view)
        {
            var model = Repository.GetById <MealMenu>(view.Id);

            model.ModifiedAt         = DateTime.Now;
            model.ModifiedBy         = view.ModifiedBy;
            model.ModifiedByFullName = view.ModifiedByFullName;
            model.ModifiedReason     = view.ModifiedReason;
            model.RecordStatus       = (long)RecordStatuses.Deleted;
            Repository.Update(model);
        }
コード例 #3
0
        public MealMenuView Update(MealMenuView view)
        {
            var      dtNow = DateTime.Now;
            MealMenu model;
            MealMenu duplicatedMealMenu = null;

            if (view.Id > 0)
            {
                model = Repository.GetById <MealMenu>(view.Id);
            }
            else
            {
                duplicatedMealMenu = (from mealMenu in Repository.Query <MealMenu>()
                                      where
                                      mealMenu.MealType == view.MealType.Id &&
                                      mealMenu.ValidDate == view.ValidDate.Date &&
                                      mealMenu.Menu.Id == view.Menu.Id &&
                                      mealMenu.RecordStatus == (long)RecordStatuses.Active
                                      select mealMenu).FirstOrDefault();
                if (duplicatedMealMenu == null)
                {
                    model = new MealMenu
                    {
                        Menu               = Repository.GetById <Menu>(view.Menu.Id),
                        ModifiedAt         = dtNow,
                        ModifiedReason     = view.ModifiedReason,
                        ModifiedBy         = view.ModifiedBy,
                        ModifiedByFullName = view.ModifiedByFullName,
                        RecordStatus       = (long)RecordStatuses.Active
                    };
                }
                else
                {
                    model = duplicatedMealMenu;
                }
            }
            if (duplicatedMealMenu == null)
            {
                model.MealType  = (int)view.MealType.Id;
                model.ValidDate = view.ValidDate.Date;
                if (model.Id == 0)
                {
                    model.CreatedAt         = dtNow;
                    model.CreatedBy         = view.ModifiedBy;
                    model.CreatedByFullName = view.ModifiedByFullName;
                }

                Repository.Update(model);
            }
            return(model.ToView <MealMenuView>());
        }
コード例 #4
0
 public static void SetTo(this MealMenuView view, MealMenu model)
 {
     Mapper.Map(view, model);
 }
コード例 #5
0
 public static MealMenu ToModel(this MealMenuView view)
 {
     return(Mapper.Map <MealMenu>(view));
 }
コード例 #6
0
 public MealMenuView Create(MealMenuView view)
 {
     return(Update(view));
 }