public PartialViewResult LoadExistingDetail(Guid id) { var viewModel = new BeautyHairDetailsViewModel(); ServiceBll serviceBll = new ServiceBll(); if (id != Guid.Empty) { var service = serviceBll.SelectById(id, CurrentUser.UserId); if (service != null) { viewModel.Id = service.Id; //var ServiceType = this.serviceBll.SelectById(service.ServiceTypeId, CurrentUser.UserId); //if (ServiceType != null) //{ // viewModel.ServiceServiceType = ServiceType.Description; // var group = this.ServiceGroupBll.SelectById(ServiceType.ServiceGroupId, CurrentUser.UserId); // if (group != null) // viewModel.ServiceServiceClass = group.Description; //} //var location = this.LocationBll.SelectById(Service.LocationId, CurrentUser.UserId); //if (location != null) //{ // viewModel.ServiceLocationDescription = location.Description; //} } else { throw new Exception("Service not found for Id passed through"); } } else { //SelectListViewData(null); //this.LoadServiceTypesIntoViewData(null, "ServiceTypeId", false, null); //this.LoadServiceRoomIntoViewData(null, "ServiceRoomId", false); //this.LoadStocktakeIntoViewData(null, "StocktakeId", false); } //var jsonViewModel = new JsonViewModel(); //jsonViewModel.Html = base.RenderPartialViewToString("Details", viewModel); //jsonViewModel.HasErrors = false; //jsonViewModel.IsValid = true; //return Json(jsonViewModel); return PartialView("Details", viewModel); }
public PartialViewResult ManageDetail(BeautyHairDetailsViewModel viewModel) { if (ModelState.IsValid) { ServiceBll serviceBll = new ServiceBll(); try { var item = new Service(); if (viewModel.Id != Guid.Empty) item = serviceBll.SelectById(viewModel.Id, CurrentUser.UserId); item.Id = viewModel.Id; item.ServiceCategory = viewModel.ServiceCategory; item.ServiceName = viewModel.ServiceName; if (viewModel.Id == Guid.Empty) serviceBll.Insert(item, CurrentUser.UserId); else { serviceBll.Update(item, CurrentUser.UserId); } } catch (Exception ex) { viewModel.AddModelError("SYSTEM ERROR - " + ex.Message); //Logger.Instance.Log.Error("Service Controller - ManageDetail (POST) - " + ex.Message); } } //SelectListViewData(viewModel.Id); //this.LoadServiceTypesIntoViewData(viewModel.ServiceTypeId, "ServiceTypeId", false, null); //this.LoadServiceRoomIntoViewData(viewModel.ServiceRoomId, "ServiceRoomId", false); //this.LoadServiceTypesIntoViewData(null, "SearchServiceTypeId", false, null); //this.LoadServiceRoomIntoViewData(null, "SearchServiceRoomId", false); return PartialView("Details", viewModel); }
/// <summary> /// Default constructor /// </summary> public ManageBeautyHairViewModel() { ListViewModel = new BeautyHairListViewModel(); DetailsViewModel = new BeautyHairDetailsViewModel(); }