public async Task <ActionResult> EditSubBrand(Guid id, EditSubBrandViewModel request) { if (!ModelState.IsValid) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } if (!id.Equals(request.Id)) { Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } try { var subBrandEditRequest = new UpdateSubBrandRequest { Id = request.Id, Name = request.Name, Description = request.Description, BrandId = request.BrandId }; var result = await _subBrandService.Update(id, subBrandEditRequest); if (!result.Success) { Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } Alert($"Sub Brand Updated Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } catch { Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } }
public async Task <ActionResult> EditSubBrand(Guid id) { var subBrand = new EditSubBrandViewModel(); try { var result = await _subBrandService.FindByIdInclusive(id, x => x.Include(p => p.Brand)); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(subBrand)); } subBrand.Id = result.Data.Id; subBrand.Name = result.Data.Name; subBrand.Description = result.Data.Description; subBrand.BrandId = result.Data.Brand.Id; subBrand.BrandName = result.Data.Brand.Name; return(View(subBrand)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(subBrand)); } }