public async Task <ContactExcerptDto> CreateContactAsync(NewContactDto newContact, CancellationToken cancellationToken) { this.securityService.Ensure(SecurityEntityTypes.Contact, SecurityMethods.Create); if (newContact == null) { throw new ArgumentNullException(nameof(newContact)); } this.contactValidator.ValidateContact(newContact); Contact newContactModel = this.mapper.Map <Contact>(newContact); Contact createdContact = await this.contactRepository.CreateContactAsync(newContactModel, cancellationToken); createdContact.CreatedBy = this.securityService.GetCurrentIdentityName(); await this.contactRepository.SaveChangesAsync(cancellationToken); ContactExcerptDto contactExcerpt = this.mapper.Map <ContactExcerptDto>(createdContact); return(contactExcerpt); }
public async Task <IHttpActionResult> CreateContactAsync(NewContactDto newContact, CancellationToken cancellationToken = default(CancellationToken)) { ContactExcerptDto contactExcerpt = await this.contactService.CreateContactAsync(newContact, cancellationToken); return(this.Ok(contactExcerpt)); }