public async Task <IActionResult> AddBox([FromBody] BoxCreationData boxCreationData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var box = await _boxService.AddBox(User.GetId(), boxCreationData); return(CreatedAtAction(nameof(GetBox), new { boxId = box.Id }, box)); }
/// <inheritdoc /> public async Task <BoxDto> AddBox(Guid userId, BoxCreationData data) { using (Context) { var box = new Core.Data.Box { User = await GetUserById(userId), Name = data.Name }; var result = await Context.AddAsync(box); await Context.SaveChangesAsync(); return(result.Entity.ToBoxDto()); } }