public async Task <IActionResult> EditServiceTypeAsync(EditServiceTypeViewModel model) { var serviceType = await _serviceTypeRepository.GetServiceTypeByIdAsync(model.Id); if (serviceType == null) { ViewBag.ErrorMessage = $"User with user id ={model.Id} cannot be found"; return(View("NotFound")); } else { serviceType.ServiceName = model.ServiceTypeName; serviceType.ServiceDescription = model.Description; serviceType.Pricing = model.Pricing; await _serviceTypeRepository.UpdateServiceTypeAsync(serviceType); return(RedirectToAction("ListServiceTypes", "Admin")); } }
public async Task <IActionResult> EditServiceTypeAsync(int id) { var serviceType = await _serviceTypeRepository.GetServiceTypeByIdAsync(id); int _serviceTypeId = id; if (serviceType == null) { ViewBag.ErrorMessage = $"User with category id ={id} cannot be found"; return(View("NotFound")); } var model = new EditServiceTypeViewModel { Id = serviceType.ServiceTypeId, ServiceTypeName = serviceType.ServiceName, Description = serviceType.ServiceDescription, Pricing = serviceType.Pricing }; return(View(model)); }