public static Lunch Map(LunchModel model, Lunch item) { item.LunchDate = model.LunchDate.Date + model.LunchTime; item.CookedMealId = model.CookedMealId; item.NumberOfPortions = model.NumberOfPortions; return(item); }
public ActionResult CreatePartial() { var lunchModel = new LunchModel() { LunchDate = LunchRepository.NextLunchDate(), LunchTime = TimeSpan.FromHours(12) + TimeSpan.FromMinutes(30), NumberOfPortions = 10 }; return(View(lunchModel)); }
public ActionResult Create(LunchModel lunchModel) { if (ModelState.IsValid) { var lunch = new Lunch(); Mapper.Map(lunchModel, lunch); LunchRepository.Insert(lunch); return(RedirectToAction("Index")); } else { return(View(lunchModel)); } }
public static LunchModel Map(Lunch item, LunchModel model) { model.LunchId = item.Id; model.LunchDate = item.LunchDate.Date; model.LunchTime = item.LunchDate.TimeOfDay; model.CookedMealId = item.CookedMealId; model.CookedMealName = item.CookedMeal.Name; model.NumberOfPortions = item.NumberOfPortions; model.Enrollments = item.Enrollments.Select(e => new EnrollmentModel() { UserName = e.EnrolledBy.Name, VariationName = e.MealVariation != null ? e.MealVariation.Name : "" }).ToList(); return(model); }
public static Lunch ToDataBaseEntity(this LunchModel lunch) { if (lunch == null) { return(null); } return(new Lunch { Id = lunch.Id, Employees = lunch.EmployeesList.ToDataBaseEntities(), LunchTime = lunch.LunchTime, //Restaurant = lunch.Restaurant.ToDataBaseEntity(), RestaurantId = lunch.Restaurant.Id, Removed = lunch.Removed }); }
public ActionResult Edit(LunchModel lunchModel) { if (ModelState.IsValid) { var lunch = LunchRepository.Get(lunchModel.LunchId); Mapper.Map(lunchModel, lunch); LunchRepository.Update(lunch); UpdateLunchInfoOnClients(lunch); return(RedirectToAction("Index")); } else { return(View(lunchModel)); } }
public ActionResult Create(Guid?mealId = null) { var lunchModel = new LunchModel() { LunchDate = LunchRepository.NextLunchDate(), LunchTime = TimeSpan.FromHours(12) + TimeSpan.FromMinutes(30), NumberOfPortions = 10 }; if (mealId.HasValue) { var meal = MealRepository.Get(mealId.Value); lunchModel.CookedMealId = meal.Id; lunchModel.CookedMealName = meal.Name; } return(View(lunchModel)); }
public bool Post(LunchModel lunch, EmployeeModel employee) { return(lunch != null && lunchRepo.Post(lunch.ToDataBaseEntity(), employee.ToDataBaseEntity())); }
public async Task <object> DeleteVendor([FromBody] LunchModel mdl) { var url = $"{LunchAppUrl}DeleteVendors/{mdl.pkId}/{mdl.CompanyId}"; return(await _hcmAdminClient.SendDataToAPI(url, "DELETE", false)); }
public async Task <object> PutVendor([FromBody] LunchModel mdl) { var url = $"{LunchAppUrl}UpdateVendors/{mdl.pkId}/{mdl.CompanyId}"; return(await _hcmAdminClient.SendDataToAPI(url, "PUT", false, mdl)); }
public async Task <string> GetAllVendors([FromBody] LunchModel mdl) { var url = $"{LunchAppUrl}GetAllVendor/{mdl.CompanyId}"; return(await _hcmAdminClient.SendDataToAPI(url, "GET", false)); }