예제 #1
0
파일: CompanySaga.cs 프로젝트: zszqwe/Merp
        public async Task Handle(ChangeCompanyContactInfoCommand message)
        {
            var company = _repository.GetById <Company>(message.CompanyId);

            if (company.ContactInfo == null || message.PhoneNumber != company.ContactInfo.PhoneNumber || message.FaxNumber != company.ContactInfo.FaxNumber || message.WebsiteAddress != company.ContactInfo.WebsiteAddress || message.EmailAddress != company.ContactInfo.EmailAddress)
            {
                company.SetContactInfo(message.PhoneNumber, null, message.FaxNumber, message.WebsiteAddress, message.EmailAddress, null, message.UserId);
                await _repository.SaveAsync(company);
            }
        }
예제 #2
0
 public Task Handle(ChangeCompanyContactInfoCommand message)
 {
     return(Task.Factory.StartNew(() => {
         var company = _repository.GetById <Company>(message.CompanyId);
         if (company.ContactInfo == null || message.PhoneNumber != company.ContactInfo.PhoneNumber || message.FaxNumber != company.ContactInfo.FaxNumber || message.WebsiteAddress != company.ContactInfo.WebsiteAddress || message.EmailAddress != company.ContactInfo.EmailAddress)
         {
             company.SetContactInfo(message.PhoneNumber, null, message.FaxNumber, message.WebsiteAddress, message.EmailAddress, null);
             _repository.Save(company);
         }
     }));
 }
        public void ChangeContactInfo(ChangeContactInfoViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var cmd = new ChangeCompanyContactInfoCommand(model.CompanyId, model.PhoneNumber, model.FaxNumber, model.WebsiteAddress, model.EmailAddress);

            Bus.Send(cmd);
        }
예제 #4
0
        public async Task ChangeContactInfoAsync(Guid companyId, ChangeContactInfoModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var userId = GetCurrentUserId();

            var cmd = new ChangeCompanyContactInfoCommand(userId, companyId, model.PhoneNumber, model.FaxNumber, model.WebsiteAddress, model.EmailAddress);

            await Bus.Send(cmd);
        }