public async Task <ActionResult> CreateSubBrand(AddSubBrandViewModel request) { if (!ModelState.IsValid) { Alert($"Invalid Request.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } try { var addSubBrandRequest = new AddSubBrandRequest { BrandId = request.BrandId, Name = request.Name, Description = request.Description }; var result = await _subBrandService.Create(addSubBrandRequest); if (!result.Success) { Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } Alert($"Sub Brand Created Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } catch (Exception ex) { Alert($"Error! {ex.Message}.", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime)); return(RedirectToAction(nameof(SubBrands), new { id = request.BrandId })); } }
public ActionResult CreateSubBrand(Guid brandId, string BrandName) { var sb = new AddSubBrandViewModel { BrandId = brandId }; ViewBag.brandName = BrandName; return(View(sb)); }