public bool UpdateCardList(int cardlistId, UpdateCardListDTO cardListDTO, string username) { bool ret = false; using (UnitOfWork unit = new UnitOfWork()) { CardList cardList = unit.CardListRepository.GetById(cardlistId); if (cardList != null) { cardList.Name = cardListDTO.Name; cardList.Color = cardListDTO.Color; unit.CardListRepository.Update(cardList); ret = unit.Save(); if (ret) { BasicCardListDTO dto = new BasicCardListDTO(cardList); RabbitMQService.PublishToExchange(cardList.Board.ExchangeName, new MessageContext(new CardListMessageStrategy(dto, MessageType.Update, username))); BoardNotificationService.ChangeBoardNotifications(cardList.Board.BoardId); } } } return(ret); }
public bool Put(int id, [FromBody] UpdateCardListDTO cardList) { if (cardList != null) { return(service.UpdateCardList(id, cardList, User.Identity.Name)); } return(false); }
public static async Task <bool> UpdateCardList(string accessToken, int cardListId, UpdateCardListDTO updateListDTO) { using (HttpClient client = new HttpClient()) { try { string json = JsonConvert.SerializeObject(updateListDTO); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); client.DefaultRequestHeaders.Add("Authorization", accessToken); var response = await client.PutAsync("http://localhost:52816/api/CardList/" + cardListId, byteContent); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var jsonString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <bool>(jsonString); return(result); } else { return(false); } } catch (Exception e) { Debug.WriteLine(e.Message); return(false); } } }