Пример #1
0
 public void CreateProduct(DTOs.Product product)
 {
     usersWebService.products prod = new usersWebService.products();
     prod.productid          = (int)product.Id;
     prod.productname        = product.Name;
     prod.productdescription = product.Description;
     context.products.Add(prod);
 }
Пример #2
0
 public void UpdateProduct(DTOs.Product product, int productid)
 {
     DTOs.Product             prods = GetById(productid);
     usersWebService.products prod  = new usersWebService.products();
     prod.productid = (int)prods.Id;
     context.products.Remove(prod);
     prod.productid          = (int)product.Id;
     prod.productname        = product.Name;
     prod.productdescription = product.Description;
     context.products.Add(prod);
     //context.Entry(product).State = EntityState.Modified;
     Save();
 }
Пример #3
0
        public void AddProduct(DTOs.Product product, DTOs.ProductDetails productDetails)
        {
            using (APShopContext context = new APShopContext())
            {
                UnitOfWork                  UoW              = new UnitOfWork(context);
                EntityModels.Product        EMProduct        = _mapper.Map <EntityModels.Product>(product);
                EntityModels.ProductDetails EMProductDetails = _mapper.Map <EntityModels.ProductDetails>(productDetails);

                UoW.Product.AddProduct(EMProduct);
                EMProduct.ProductDetails.Add(EMProductDetails);

                UoW.commit();
            }
        }
 public void CreateProduct(DTOs.Product product)
 {
     usersWebService.Product prod = new usersWebService.Product();
     prod.ID              = (int)product.Id;
     prod.Ean             = product.Ean;
     prod.CategoryId      = product.CategoryId;
     prod.CategoryName    = product.CategoryName;
     prod.BrandId         = product.BrandId;
     prod.BrandName       = product.BrandName;
     prod.Name            = product.Name;
     prod.Description     = product.Description;
     prod.Price           = product.Price;
     prod.ExpectedRestock = product.ExpectedRestock;
     prod.InStock         = product.InStock;
     prod.Supplier        = product.Supplier;
     context.Product.Add(prod);
 }
        public DTOs.Product GetById(int id)
        {
            var data = context.Product.ToList();

            DTOs.Product prod = data.Where(p => p.ID == id).Select(p => new DTOs.Product
                                                                   (
                                                                       ID: p.ID,
                                                                       Ean: p.Ean,
                                                                       CategoryID: p.CategoryId,
                                                                       CategoryName: p.CategoryName,
                                                                       BrandID: p.BrandId,
                                                                       BrandName: p.BrandName,
                                                                       Name: p.Name,
                                                                       Description: p.Description,
                                                                       Price: p.Price,
                                                                       expectedRestock: p.ExpectedRestock,
                                                                       inStock: p.InStock,
                                                                       Supplier: p.Supplier
                                                                   )).FirstOrDefault();
            return(prod);
        }
Пример #6
0
        public Product GetById(int id)
        {
            var data = context.products.ToList() :
                           DTOs.Product prod = data.Where(p => p.productid == id).Select(p => new DTOs.Product
            {
                Id              = p.Id,
                Ean             = p.Ean,
                CategoryId      = p.CategoryId,
                CategoryName    = p.CategoryName,
                BrandId         = p.BrandId,
                BrandName       = p.BrandName,
                Name            = p.Name,
                Description     = p.Description,
                Price           = p.Price,
                ExpectedRestock = p.ExpectedRestock,
                InStock         = p.InStock,
                Supplier        = p.Supplier
            }).FirstOrDefault();

            return(prod);
        }
 public void UpdateProduct(DTOs.Product product, int Id)
 {
     DTOs.Product            prods = GetById(Id);
     usersWebService.Product prod  = new usersWebService.Product();
     prod.ID = (int)prods.Id;
     context.Product.Remove(prod);
     prod.ID              = (int)product.Id;
     prod.Ean             = product.Ean;
     prod.CategoryId      = product.CategoryId;
     prod.CategoryName    = product.CategoryName;
     prod.BrandId         = product.BrandId;
     prod.BrandName       = product.BrandName;
     prod.Name            = product.Name;
     prod.Description     = product.Description;
     prod.Price           = product.Price;
     prod.ExpectedRestock = product.ExpectedRestock;
     prod.InStock         = product.InStock;
     prod.Supplier        = product.Supplier;
     context.Product.Add(prod);
     //context.Entry(product).State = EntityState.Modified;
     Save();
 }
Пример #8
0
        public bool UpdateProduct(DTOs.Product product, DTOs.ProductDetails productDetails)
        {
            using (APShopContext context = new APShopContext())
            {
                UnitOfWork                  UoW              = new UnitOfWork(context);
                EntityModels.Product        EMProduct        = _mapper.Map <EntityModels.Product>(product);
                EntityModels.ProductDetails EMProductDetails = _mapper.Map <EntityModels.ProductDetails>(productDetails);

                var Exists = UoW.Product.GetByCode(product.Code);

                if (Exists != null)
                {
                    Exists.IsActive = false;
                    UoW.Product.AddProduct(EMProduct);
                    EMProduct.ProductDetails.Add(EMProductDetails);
                    UoW.commit();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }