public ISoldProductAccomplishedModel FindById(int id) { SoldProductAccomplished item = _db.SoldProductsAccomplished.Find(id); ISoldProductAccomplishedModel model = MapTheSoldProductAccomplishedObject(item); return(model); }
// POST: api/SoldProductsAccomplished public void Post([FromBody] SoldProductAccomplishedModel product) { if (ModelState.IsValid) { ISoldProductAccomplishedModel model = product; soldProductAccomplishedData.Create(model); } }
/// <summary> /// It completes the payment for all products of the List /// </summary> public static void PaySoldProducts(List <ISoldProductModel> sold, ISoldProductDataAccess soldProductData, ISoldProductAccomplishedDataAccess soldProductAccomplishedData) { foreach (ISoldProductModel product in sold) { ISoldProductAccomplishedModel auxProduct = MappingObjects.SoldProductToSoldProductAccomplished(product); soldProductAccomplishedData.Create(auxProduct); } soldProductData.DeleteList(sold); }
public void Create(ISoldProductAccomplishedModel model) { SoldProductAccomplished item = new SoldProductAccomplished(); item.Name = model.Name; item.CategoryID = model.CategoryID; item.Price = model.Price; _db.SoldProductsAccomplished.Add(item); _db.SaveChanges(); }
/// <summary> /// It maps an object of type SoldProductModel to SoldProductAccomplishedModel /// </summary> public static ISoldProductAccomplishedModel SoldProductToSoldProductAccomplished(ISoldProductModel product) { ISoldProductAccomplishedModel soldProductAccomplished = Factory.InstanceSoldProductAccomplishedModel(); soldProductAccomplished.Name = product.Name; soldProductAccomplished.CategoryID = product.CategoryID; soldProductAccomplished.Price = product.Price; soldProductAccomplished.Category.ID = product.CategoryID; soldProductAccomplished.Category.Name = product.Category.Name; return(soldProductAccomplished); }
private ISoldProductAccomplishedModel MapTheSoldProductAccomplishedObject(SoldProductAccomplished item) { ISoldProductAccomplishedModel model = Factory.InstanceSoldProductAccomplishedModel(); model.ID = item.ID; model.Name = item.Name; model.CategoryID = item.CategoryID; model.Category.ID = item.CategoryID; model.Price = item.Price; return(model); }
public void Create(ISoldProductAccomplishedModel model) { using (var post = APIClientConfig.ApiClient.PostAsJsonAsync("soldproductsaccomplished", model)) { post.Wait(); if (post.Result.IsSuccessStatusCode) { } else { throw new Exception(post.Result.ReasonPhrase); } } }
public void SoldProductToSoldProductAccomplished_ShouldBeMapped() { ISoldProductModel soldProduct = Factory.InstanceSoldProductModel(); soldProduct.Name = "some product"; soldProduct.Price = 999.93M; soldProduct.Category.Name = "some category"; soldProduct.Category.ID = 897; soldProduct.CategoryID = 897; ISoldProductAccomplishedModel soldProductAccomplished = MappingObjects.SoldProductToSoldProductAccomplished(soldProduct); Assert.Equal(soldProduct.Name, soldProductAccomplished.Name); Assert.Equal(soldProduct.Price, soldProductAccomplished.Price); soldProductAccomplished.Category.Should().BeEquivalentTo(soldProduct.Category); }
public ISoldProductAccomplishedModel FindById(int id) { using (var response = APIClientConfig.ApiClient.GetAsync($"soldproductsaccomplished/{id}")) { response.Wait(); if (response.Result.IsSuccessStatusCode) { var readTask = response.Result.Content.ReadAsAsync <SoldProductAccomplishedModel>(); readTask.Wait(); ISoldProductAccomplishedModel model = readTask.Result; return(model); } else { throw new Exception(response.Result.ReasonPhrase); } } }
/// <summary> /// It completes the payment of selected items in a list based in indexes from variable "Paid" /// </summary> public static void PaySelectedSoldProducts(List <ISoldProductModel> fullList, int[] Paid, ISoldProductDataAccess soldProductData, ISoldProductAccomplishedDataAccess soldProductAccomplishedData) { List <ISoldProductModel> sold = Factory.InstanceISoldProductModelList(); foreach (int item in Paid) { ISoldProductModel product = Factory.InstanceSoldProductModel(); product = fullList[item]; ISoldProductAccomplishedModel auxProduct = MappingObjects.SoldProductToSoldProductAccomplished(product); soldProductAccomplishedData.Create(auxProduct); sold.Add(product); } foreach (ISoldProductModel element in sold) { fullList.Remove(element); } soldProductData.DeleteList(sold); }