コード例 #1
0
        public async Task <ActionResult> AddFromAddressBook(Guid id)
        {
            var carriers = await mediator.SendAsync(new GetUserAddressBookByType(AddressRecordType.Carrier));

            var model = new AddFromAddressBookViewModel();

            model.SetCarriers(carriers.AddressRecords);

            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult> AddFromAddressBook(Guid id, AddFromAddressBookViewModel model,
                                                            string command, string remove)
        {
            if (command != null && command == "addcarrier")
            {
                if (model.SelectedCarrier.HasValue && !model.SelectedCarriers.Contains(model.SelectedCarrier.Value))
                {
                    model.SelectedCarriers.Add(model.SelectedCarrier.Value);
                }
            }
            else if (command != null && command == "continue")
            {
                if (model.SelectedCarriers.Any())
                {
                    await mediator.SendAsync(new AddCarriersToNotificationFromAddressBook(id,
                                                                                          model.SelectedCarriers.ToArray()));
                }

                return(RedirectToAction("List"));
            }
            else if (remove != null)
            {
                model.SelectedCarriers.RemoveAll(c => c.ToString().Equals(remove));
            }

            var carriers = await mediator.SendAsync(new GetUserAddressBookByType(AddressRecordType.Carrier));

            model.SetCarriers(carriers.AddressRecords);

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  NotificationAuditType.Added,
                                                  NotificationAuditScreenType.IntendedCarrier);

            return(View(model));
        }