public async Task <Guid> AddAsync(WebsiteAddModel model) { if (model == null) { throw new ArgumentNullException(); } await ValidateNameUniquenessAsync(model.Name); Guid categoryId = await GetCategoryIdAsync(model.CategoryCode); User login = userService.CreateUser(model.Login); Website website = new Website { Name = model.Name, URL = model.URL, CategoryId = categoryId, HomepageSnapshot = Convert.FromBase64String(model.HomepageSnapshot), Login = login }; context.Websites.Add(website); await context.SaveChangesAsync(); return(website.Id); }
public async Task <IActionResult> PostAsync([FromBody] WebsiteAddModel model) { Guid id = await websiteService.AddAsync(model); return(Created(nameof(PostAsync), new { id })); }