コード例 #1
0
        public Task <RequestResult <ListModel> > UpdateListAsync(ListModel list, string newTitle)
        {
            var dto = new UpdateListDto
            {
                Id      = list.Id,
                Title   = newTitle,
                Version = list.Version
            };


            return(_webApiClient.ExecuteRequestAsync(webApi => webApi.UpdateList(dto)));
        }
コード例 #2
0
        public IActionResult UpdateList([FromBody] UpdateListDto updateListDto)
        {
            try
            {
                var listEntity = _listService.Get(updateListDto.Id);
                if (!(updateListDto.Name is null))
                {
                    listEntity.Name = updateListDto.Name;
                }
                if (updateListDto.OrderNumber.HasValue)
                {
                    listEntity.OrderNumber = updateListDto.OrderNumber.Value;
                }
                if (updateListDto.IsArchived.HasValue)
                {
                    // TODO: archive/restore its cards

                    if (updateListDto.IsArchived.Value)
                    {
                        // Archive card
                        listEntity.IsArchived = true;
                        listEntity.Archived   = DateTime.Now;
                    }
                    else
                    {
                        // Restore card
                        listEntity.IsArchived = false;
                        listEntity.Archived   = null;
                    }
                }
                _listService.Update(listEntity);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }