Exemplo n.º 1
0
 public ActionResult AssociateMainContact(AssociateMainContactViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         return(View(model));
     }
     WorkerServices.AssociateMainContact(model);
     return(RedirectToRoute("registry", new { }));
 }
        public void AssociateMainContact(AssociateMainContactViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var cmd = new AssociateMainContactToCompanyCommand(model.CompanyId, model.MainContact.OriginalId);

            Bus.Send(cmd);
        }
        public AssociateMainContactViewModel GetAssociateMainContactViewModel(Guid companyId)
        {
            var company = Repository.GetById <Company>(companyId);
            var model   = new AssociateMainContactViewModel()
            {
                CompanyId   = company.Id,
                CompanyName = company.CompanyName
            };

            if (company.MainContactId.HasValue)
            {
                model.MainContact = Database.Parties.OfType <Merp.Registry.QueryStack.Model.Person>()
                                    .Where(p => p.OriginalId == company.MainContactId.Value)
                                    .Select(p => new PersonInfo {
                    Id = p.Id, OriginalId = p.OriginalId, Name = p.DisplayName
                })
                                    .Single();
            }

            return(model);
        }