public async Task <Item> UpdateItemAsync(UpdateBoardDto model)
        {
            var userId   = long.Parse(_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var boardOld =
                await(await _itemService.GetAllAsync(d => d.Id == model.Id)).FirstOrDefaultAsync();

            if (boardOld == null)
            {
                throw new ObjectNotFoundException("Item not found.");
            }

            var boardWithSameName =
                await(await _itemService.GetAllAsync(d => d.Name == model.Name)).FirstOrDefaultAsync();

            if (boardWithSameName != null && model.Id != boardWithSameName.Id)
            {
                throw new ObjectAlreadyExistException("Item with same name already exist.");
            }

            var board =
                await _itemService.UpdateAsync(model.ToBoard(boardOld, userId));

            //return board.ToBoardReturnDto();
            return(board);
        }
 public static Item ToBoard(this UpdateBoardDto model, Item item, long modifiedBy)
 {
     item.Name        = model.Name;
     item.Description = model.Description;
     item.UpdatedBy   = modifiedBy;
     return(item);
 }
 public static Board ToBoard(this UpdateBoardDto model, Board board, long modifiedBy)
 {
     board.Name        = model.Name;
     board.Description = model.Description;
     board.IsPrivate   = model.IsPrivate;
     board.UpdatedBy   = modifiedBy;
     return(board);
 }
Beispiel #4
0
        public Board UpdateBoard(Guid id, UpdateBoardDto dto)
        {
            var board = _unitOfWork.Repository <Board>().Find(id);

            board.ImageUrl   = dto.ImageUrl;
            board.Name       = dto.Name;
            board.PhaseOrder = JsonConvert.SerializeObject(dto.PhaseOrder);

            _unitOfWork.Repository <Board>().Update(board);
            _unitOfWork.Complete();

            return(board);
        }
        public async Task <IActionResult> UpdateBoard(
            UpdateBoardDto model
            )
        {
            try
            {
                var responsePayload = await _boardService.UpdateBoardAsync(model);

                return(Ok(responsePayload));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { ex.Message }));
            }
        }
Beispiel #6
0
        public IActionResult UpdateBoardInfo([FromBody] UpdateBoardDto updateBoardDto)
        {
            try
            {
                var boardEntity = _boardService.Get(updateBoardDto.Id);
                if (!(updateBoardDto.Name is null))
                {
                    boardEntity.Name = updateBoardDto.Name;
                }
                if (!(updateBoardDto.Description is null))
                {
                    boardEntity.Description = updateBoardDto.Description;
                }
                _boardService.Update(boardEntity);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
        public BaseResponse <BoardOutputDto> Update([FromBody] UpdateBoardDto boardDto, Guid id)
        {
            var res = _boardService.UpdateBoard(id, boardDto);

            return(new SuccessResponse <BoardOutputDto>(_mapper.Map <BoardOutputDto>(res)));
        }