public IHttpActionResult Post(ShoppingProductBTO shoppingProductBTO) { ShoppingProductLogic shoppingProduct = new ShoppingProductLogic(); var model = shoppingProduct.Create(shoppingProductBTO); return(CreatedAtRoute("DefaultApi", new { id = model.Id }, model)); }
//Update public void Update(ShoppingProductBTO existingShoppingProductBTO) { UnitOfWork unitOfWork = new UnitOfWork(context); unitOfWork.ShoppingProductRepo.Update(existingShoppingProductBTO.ShoppingProductBTOToShoppingProduct()); unitOfWork.Save(); }
//Create public ShoppingProductBTO Create(ShoppingProductBTO bto) { UnitOfWork unitOfWork = new UnitOfWork(context); var response = unitOfWork.ShoppingProductRepo.Create(bto.ShoppingProductBTOToShoppingProduct()); unitOfWork.Save(); return(response.ShoppingProductToShoppingProductBTO()); }
public static ShoppingProduct ShoppingProductBTOToShoppingProduct(this ShoppingProductBTO bto) { return(new ShoppingProduct { id = bto.Id, productId = bto.ProductId, quantity = bto.quantity, shoppingBasketId = bto.ShoppingBasketId //ShoppingBasketId = bto.ShoppingBasketId.ShoppingBasketBTOToShoppingBasket() }); }
//RetrieveAll public List <ShoppingProductBTO> RetrieveAll() { UnitOfWork unitOfWork = new UnitOfWork(context); List <ShoppingProductBTO> Listbto = new List <ShoppingProductBTO>(); foreach (var item in unitOfWork.ShoppingProductRepo.RetrieveAll()) { ShoppingProductBTO btoToAdd = this.Retrieve(item.id); Listbto.Add(btoToAdd); } return(Listbto); }
public IHttpActionResult Put(ShoppingProductBTO shoppingProductBTO) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } ShoppingProductLogic shoppingProduct = new ShoppingProductLogic(); var existingShoppingProduct = shoppingProduct.Retrieve(shoppingProductBTO.Id); if (existingShoppingProduct != null) { shoppingProduct.Update(shoppingProductBTO); } else { return(NotFound()); } return(Ok()); }