public async Task <ActionResult> DeleteSubBrand(Guid id, SubBrandDetailsViewModel request) { if (!ModelState.IsValid) { Alert("Bad Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } if (id == null) { Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } try { var result = await _subBrandService.Delete(id); if (!result.Success) { Alert($"Error! {result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } Alert($"Sub Brand Deleted 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(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } }
public async Task <ActionResult> DeleteSubBrand(Guid id) { if (id == null) { Alert($"Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View()); } var subBrand = new SubBrandDetailsViewModel(); 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.Code = result.Data.Code; subBrand.Id = result.Data.Id; subBrand.Name = result.Data.Name; subBrand.Description = result.Data.Description; subBrand.DateCreated = result.Data.CreatedAt; subBrand.DateLastUpdated = result.Data.LastUpdated; subBrand.BrandName = result.Data.Brand.Name; subBrand.BrandId = result.Data.Brand.Id; return(View(subBrand)); } catch (Exception ex) { Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(View(subBrand)); } }