public async Task <IActionResult> UpdateWishCartItem( [FromBody] WishCartItem wishListEventToUpdate) { var wishListItem = await _wishListContext.WishCartItems .SingleOrDefaultAsync (i => i.Id == wishListEventToUpdate.Id); if (wishListItem == null) { return(NotFound(new { Message = $"Event with id {wishListEventToUpdate.Id} not found." })); } wishListItem.BuyerId = wishListEventToUpdate.BuyerId; wishListItem.EventId = wishListEventToUpdate.EventId; wishListItem.EventTitle = wishListEventToUpdate.EventTitle; wishListItem.TicketPrice = wishListEventToUpdate.TicketPrice; wishListItem.NumOfTickets = wishListEventToUpdate.NumOfTickets; wishListItem.TicketType = wishListEventToUpdate.TicketType; _wishListContext.WishCartItems.Update(wishListItem); await _wishListContext.SaveChangesAsync(); var result = GetWishListCartItemById(wishListEventToUpdate.Id); return(Ok(result)); // return CreatedAtRoute(nameof(GetWishListCartItemById), new { id = wishListEventToUpdate.Id }); }
public async Task <IActionResult> AddWishCartItem( [FromBody] WishCartItem wishCartItem) { var item = new WishCartItem { BuyerId = wishCartItem.BuyerId, EventId = wishCartItem.EventId, EventTitle = wishCartItem.EventTitle, TicketPrice = wishCartItem.TicketPrice, NumOfTickets = wishCartItem.NumOfTickets, TicketType = wishCartItem.TicketType }; _wishListContext.WishCartItems.Add(item); await _wishListContext.SaveChangesAsync(); var result = GetWishListCartItemById(item.Id); // return CreatedAtAction(nameof(GetWishListCartItemById), new { id = item.Id }); return(Ok(result)); }