public async Task <ActionResult <UrlDTO> > Create(UrlDTO urlDto) { if (!ModelState.IsValid) { return(BadRequest()); } var url = new Url { LongUrl = urlDto.Url }; await _dbContext.Urls.AddAsync(url); await _dbContext.SaveChangesAsync(); var urlService = new UrlService(); var shortUrl = urlService.Encode(url.IdHash); return(new UrlDTO() { Url = shortUrl }); }