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);
        }
Example #2
0
        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(Guid id, bool? backToOverview = null)
 {
     ViewBag.BackToOverview = backToOverview.GetValueOrDefault();
     var model = new AddCarrierViewModel { NotificationId = id };
     await this.BindCountryList(mediator);
     model.Address.DefaultCountryId = this.GetDefaultCountryId();
     return View(model);
 }
Example #4
0
 public AddAddressBookEntry Map(AddCarrierViewModel source)
 {
     return(new AddAddressBookEntry
     {
         Address = source.Address,
         Business = source.Business.ToBusinessInfoData(),
         Contact = source.Contact,
         Type = AddressRecordType.Carrier
     });
 }
Example #5
0
        public async Task Add_InvalidModel_ReturnsView()
        {
            var model = new AddCarrierViewModel();

            carrierController.ModelState.AddModelError("Test", "Error");

            var result = await carrierController.Add(model) as ViewResult;

            Assert.Equal(string.Empty, result.ViewName);
        }
Example #6
0
        public async Task <ActionResult> Add(Guid id)
        {
            var model = new AddCarrierViewModel {
                NotificationId = id
            };

            await this.BindCountryList(mediator);

            model.Address.DefaultCountryId = this.GetDefaultCountryId();
            return(View(model));
        }
Example #7
0
        public async Task <ActionResult> Add(Guid id, bool?backToOverview = null)
        {
            ViewBag.BackToOverview = backToOverview.GetValueOrDefault();
            var model = new AddCarrierViewModel {
                NotificationId = id
            };

            await this.BindCountryList(mediator);

            model.Address.DefaultCountryId = this.GetDefaultCountryId();
            return(View(model));
        }
Example #8
0
        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));
        }
        public async Task Add_InvalidModel_ReturnsView()
        {
            var model = new AddCarrierViewModel();

            carrierController.ModelState.AddModelError("Test", "Error");

            var result = await carrierController.Add(model) as ViewResult;

            Assert.Equal(string.Empty, result.ViewName);
        }