public int AddItem([FromBody] WhishListItem item) { using (var db = new WhishListContext()) { db.WhishList.Add(item); db.SaveChanges(); return(item.WhishListItemId); } }
public async Task AddToWhishList([FromForm] WishListDTO wishListDto) { var whishList = _mapper.Map <WishListDTO, WhishListItem>(wishListDto); whishList = new WhishListItem { ProductId = wishListDto.ProductId, UserId = wishListDto.UserId }; Database.WishListPrepository.Add(whishList); await Database.SaveAsync(); }