public JsonResult Delete(MealMenuView mealMenu) { mealMenu.ModifiedBy = CurrentUser.Name; mealMenu.ModifiedByFullName = CurrentUser.FullName; return(Json(MealMenuService.Delete(new MealMenuDeleteRequest { MealMenu = mealMenu }), JsonRequestBehavior.DenyGet)); }
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); }
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>()); }
public static void SetTo(this MealMenuView view, MealMenu model) { Mapper.Map(view, model); }
public static MealMenu ToModel(this MealMenuView view) { return(Mapper.Map <MealMenu>(view)); }
public MealMenuView Create(MealMenuView view) { return(Update(view)); }