Пример #1
0
 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);
 }
Пример #2
0
        public ActionResult CreatePartial()
        {
            var lunchModel = new LunchModel()
            {
                LunchDate        = LunchRepository.NextLunchDate(),
                LunchTime        = TimeSpan.FromHours(12) + TimeSpan.FromMinutes(30),
                NumberOfPortions = 10
            };

            return(View(lunchModel));
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
 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);
 }
Пример #5
0
 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
     });
 }
Пример #6
0
        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));
            }
        }
Пример #7
0
        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));
        }
Пример #8
0
 public bool Post(LunchModel lunch, EmployeeModel employee)
 {
     return(lunch != null && lunchRepo.Post(lunch.ToDataBaseEntity(), employee.ToDataBaseEntity()));
 }
Пример #9
0
        public async Task <object> DeleteVendor([FromBody] LunchModel mdl)
        {
            var url = $"{LunchAppUrl}DeleteVendors/{mdl.pkId}/{mdl.CompanyId}";

            return(await _hcmAdminClient.SendDataToAPI(url, "DELETE", false));
        }
Пример #10
0
        public async Task <object> PutVendor([FromBody] LunchModel mdl)
        {
            var url = $"{LunchAppUrl}UpdateVendors/{mdl.pkId}/{mdl.CompanyId}";

            return(await _hcmAdminClient.SendDataToAPI(url, "PUT", false, mdl));
        }
Пример #11
0
        public async Task <string> GetAllVendors([FromBody] LunchModel mdl)
        {
            var url = $"{LunchAppUrl}GetAllVendor/{mdl.CompanyId}";

            return(await _hcmAdminClient.SendDataToAPI(url, "GET", false));
        }