public async Task <IActionResult> OnGet(int StudentId) { StudentServiceVM = new StudentServiceViewModel { Student = await _db.Student.Include(c => c.ApplicationUser).FirstOrDefaultAsync(c => c.Id == StudentId), ServiceHeader = new Models.ServiceHeader() }; List <String> lstServiceTypeInShoppingCart = _db.ServiceShoppingCart .Include(c => c.OurService) .Where(c => c.StudentId == StudentId) .Select(c => c.OurService.Name) .ToList(); IQueryable <OurService> lstService = from s in _db.OurService where !(lstServiceTypeInShoppingCart.Contains(s.Name)) select s; StudentServiceVM.OurServiceList = lstService.ToList(); StudentServiceVM.ServiceShoppingCart = _db.ServiceShoppingCart .Include(c => c.OurService) .Where(c => c.StudentId == StudentId) .ToList(); StudentServiceVM.ServiceHeader.TotalPrice = 0; foreach (var item in StudentServiceVM.ServiceShoppingCart) { StudentServiceVM.ServiceHeader.TotalPrice += item.OurService.Price; } return(Page()); }
public ActionResult AddNewStudentService() { ViewBag.AlreadyExists = false; StudentServiceViewModel _item = StudentServiceViewModel.GetViewData(); _item.AllProviders = Provider.GetAll(); _item.AllEModels = Enum.GetNames(typeof(E_ServiceModel)).ToList().Select(a => a.ToString().Replace("_", " ")).ToList(); return(View(_item)); }
public JsonResult AddStudentService(StudentServiceViewModel model, List <int> studentIds) { model.AllProviders = Provider.GetAll(); model.AllEModels = Enum.GetNames(typeof(E_ServiceModel)).ToList().Select(a => a.ToString().Replace("_", " ")).ToList(); if (ModelState.IsValid) { Service.AddNew(model.CurrentService.ProviderId, model.CurrentService.Name, model.CurrentService.Model, model.CurrentService.NumberOfStudents, model.CurrentService.SessionLength, model.CurrentService.WeeklySession, model.CurrentService.SessionStart, model.CurrentService.SessionEnd, studentIds, ApplicationHelper.LoggedUserId); return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } }