public ListDto AddList(AddListDto addListDto) { if (!_context.Boards.Any(x => x.Id == addListDto.BoardId)) { return(null); } var list = new List { Name = addListDto.Name, BoardId = addListDto.BoardId }; _context.Lists.Add(list); _context.SaveChanges(); var listDto = new ListDto { Id = list.Id, BoardId = list.BoardId, Name = list.Name }; return(listDto); }
public IActionResult CreateList([FromBody] AddListDto listDto) { var userId = User.GetUserId(); var addedList = _listService.CreateList(listDto, userId); if (addedList == null) { return(BadRequest()); } return(CreatedAtRoute("GetList", new { id = addedList.Id }, addedList)); }
public IActionResult AddList([FromBody] AddListDto addListDto) { if (!ModelState.IsValid) { return(BadRequest()); } var result = _listService.AddList(addListDto); if (result == null) { return(BadRequest()); } return(Ok(result)); }
public ListDto CreateList(AddListDto listDto, string userId) { if (!_boardRepository.IsOwner(listDto.BoardId, userId)) { return(null); } var list = _mapper.Map <List>(listDto); var position = _listRepository.GetNumberOfListsInBoard(listDto.BoardId) + 1; list.Position = position; var addedList = _listRepository.CreateList(list); var result = _mapper.Map <ListDto>(addedList); return(result); }
public ListDto AddList(AddListDto addListDto) { if (!_context.Boards.Any(x => x.Id == addListDto.BoardId)) { return(null); } var list = new List { Name = addListDto.Name, BoardId = addListDto.BoardId }; _context.Lists.Add(list); _context.SaveChanges(); return(ConstructListDto(list)); }