示例#1
0
        public ISoldProductAccomplishedModel FindById(int id)
        {
            SoldProductAccomplished       item  = _db.SoldProductsAccomplished.Find(id);
            ISoldProductAccomplishedModel model = MapTheSoldProductAccomplishedObject(item);

            return(model);
        }
示例#2
0
 // POST: api/SoldProductsAccomplished
 public void Post([FromBody] SoldProductAccomplishedModel product)
 {
     if (ModelState.IsValid)
     {
         ISoldProductAccomplishedModel model = product;
         soldProductAccomplishedData.Create(model);
     }
 }
示例#3
0
        /// <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);
        }
示例#4
0
        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();
        }
示例#5
0
        /// <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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
                }
            }
        }
示例#8
0
        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);
        }
示例#9
0
        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);
                }
            }
        }
示例#10
0
        /// <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);
        }