Пример #1
0
        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));
        }