public ActionResult Manage() { centerDetailsViewModel centerVM = new centerDetailsViewModel(); if (Session["Center"] == null) { return(RedirectToAction("Login", "Account")); } int centerID = (int)Session["Center"]; BeautyCenter beautyCenter = context.BeautyCenters.Where(c => c.ID == centerID).FirstOrDefault(); if (beautyCenter.IsDeleted == true) { TempData["Message"] = "نأسف لعدم قبول المركز \n فهناك بعض البيانات التي يجب إدخالها صحيح برجاء إعادة محاولة التسجيل"; return(RedirectToAction("Index")); } if (beautyCenter.IsApproved == false) { TempData["Message"] = "شكرا لتسجيلكم معنا \n سوف يتم مراجعة البيانات والرد عليكم خلال 24 ساعة"; return(RedirectToAction("Index")); } else { centerVM.Center = beautyCenter; centerVM.centerServices = context.CentersServices.Where(c => c.isDeleted == false && c.ID == centerID).ToList(); centerVM.Employees = context.Employees.Where(c => c.IsDeleted == false && c.CenterID == centerID).ToList(); return(View(centerVM)); } }
public ActionResult createEmployee(EmployeeVM newEmp) { try { BeautyCenter center = getCenter(); int centerID = center.ID; if (!ModelState.IsValid) { return(View(newEmp)); } int empID = getEmployee(newEmp, centerID); foreach (var service in newEmp.ServiceCenterList) { if (service.isSelected) { EmployeeDoService empDoService = new EmployeeDoService() { ServiceID = service.ServiceID, EmployeeID = empID }; context.EmployeeDoServices.Add(empDoService); context.SaveChanges(); } } return(RedirectToAction("getEmployess")); } catch (Exception) { return(View(newEmp)); } }
public ActionResult getServices() { BeautyCenter center = getCenter(); int centerID = center.ID; var services = context.CentersServices.Where(cs => cs.CenterID == centerID && cs.isDeleted == false).ToList(); return(View(services)); }
public ActionResult createService() { BeautyCenter center = getCenter(); serviceCenterAdminVM serviceVM = new serviceCenterAdminVM(); serviceVM.services = context.Services.Where(c => c.IsDeleted == false).ToList(); serviceVM.centerServiceList = context.CentersServices.Where(c => c.CenterID == center.ID && c.isDeleted == false).ToList(); return(View(serviceVM)); }
public ActionResult createEmployee() { BeautyCenter center = getCenter(); int centerID = center.ID; var services = context.CentersServices.Where(cs => cs.CenterID == centerID && cs.isDeleted == false).ToList(); EmployeeVM employee = new EmployeeVM() { ServiceCenterList = services }; return(View(employee)); }
public ActionResult EditEmployee(int id) { BeautyCenter center = getCenter(); int centerID = center.ID; var services = context.CentersServices.Where(cs => cs.CenterID == centerID && cs.isDeleted == false).ToList(); EmployeeVM empVM = new EmployeeVM(); var emp = context.Employees.Where(e => e.ID == id).FirstOrDefault(); empVM.Name = emp.Name; empVM.ID = emp.ID; empVM.ServiceCenterList = services; return(View(empVM)); }
private void addBeautyCenter(AdminClientViewModel newCenter, string ImageFileName) { BeautyCenter center = new BeautyCenter() { Name = newCenter.CenterName, CityID = newCenter.CityID, Logo = ImageFileName, Gender = newCenter.Gender, Description = newCenter.Description, Address = newCenter.Address, UpdatedDate = DateTime.Now }; context.BeautyCenters.Add(center); context.SaveChanges(); }