public async Task<ActionResult> Add(AddCarrierViewModel model, bool? backToOverview = null) { if (!ModelState.IsValid) { await this.BindCountryList(mediator); return View(model); } try { await mediator.SendAsync(model.ToRequest()); if (model.IsAddedToAddressBook) { await mediator.SendAsync(addCarrierAddressBookMap.Map(model)); } return RedirectToAction("List", "Carrier", new { id = model.NotificationId, backToOverview }); } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator); return View(model); }
public async Task <ActionResult> Add(AddCarrierViewModel model) { if (!ModelState.IsValid) { await this.BindCountryList(mediator); return(View(model)); } try { await mediator.SendAsync(model.ToRequest()); await auditService.AddAuditEntry(mediator, model.NotificationId, User.GetUserId(), NotificationAuditType.Added, NotificationAuditScreenType.IntendedCarrier); return(RedirectToAction("Index", "Overview")); } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator); return(View(model)); }
public async Task <ActionResult> Add(AddCarrierViewModel model, bool?backToOverview = null) { if (!ModelState.IsValid) { await this.BindCountryList(mediator); return(View(model)); } try { await mediator.SendAsync(model.ToRequest()); await this.auditService.AddAuditEntry(this.mediator, model.NotificationId, User.GetUserId(), NotificationAuditType.Added, NotificationAuditScreenType.IntendedCarrier); if (model.IsAddedToAddressBook) { await mediator.SendAsync(addCarrierAddressBookMap.Map(model)); } return(RedirectToAction("List", "Carrier", new { id = model.NotificationId, backToOverview })); } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator); return(View(model)); }