public async Task <IActionResult> Create([FromBody] CreateContactInfoRequest contactInfoRequest) { var contactInfo = new ContactInfo { ContactId = contactInfoRequest.ContactId, Content = contactInfoRequest.Content, Type = contactInfoRequest.Type, }; await _contactInfoService.CreateAsync(contactInfo); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var getLocation = $"{baseUrl}/{APIRoutes.ContactInfoControllerRoutes.Get.Replace("{contactInfoId}", contactInfo.Id.ToString())}"; var contactInfoResponse = new ContactInfoResponse { Id = contactInfo.Id, ContactId = contactInfo.ContactId, Content = contactInfo.Content, Type = contactInfo.Type, }; await _redisCacheService .DeleteCachedResponseAsync( new string[] { HttpContext.Request.Path, APIRoutes.ContactInfoControllerRoutes.GetAll }); return(Created(getLocation, contactInfoResponse)); }
public async Task <IActionResult> Create([FromBody] CreateContactRequest contactRequest) { var contact = new Contact { FirstName = contactRequest.FirstName, LastName = contactRequest.LastName, CompanyName = contactRequest.CompanyName, OwnerUserId = HttpContext.GetCurrentUserId(), }; await _contactService.CreateAsync(contact); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var createdLocationUri = $"{baseUrl}/{APIRoutes.ContactControllerRoutes.Get.Replace("{contactId}", contact.Id.ToString())}"; var contactResponse = new ContactResponse { Id = contact.Id, FirstName = contact.FirstName, LastName = contact.LastName, CompanyName = contact.CompanyName, }; await _redisCacheService .DeleteCachedResponseAsync( new string[] { HttpContext.Request.Path, APIRoutes.ContactControllerRoutes.GetAll }); return(Created(createdLocationUri, contactResponse)); }