Exemplo n.º 1
0
        public ActionResult AddToCart(int productID)
        {
            // call the method and map the info to the productInfo
            ProductPO productInfo = _mapper.Map(_productDataAccess.ViewOneProduct(productID));

            // create a new instance of cartPO
            CartPO _CheckOut = new CartPO();

            // set correct values to the _checkOut
            _CheckOut.checkOutTotal    = productInfo.productPrice;
            _CheckOut.productID        = productID;
            _CheckOut.productQuantity  = productInfo.productQuantity;
            _CheckOut.supplierID       = productInfo.supplierID;
            _CheckOut.supplierName     = productInfo.supplierName;
            _CheckOut.userTableID      = (int)Session["userTableID"];
            _CheckOut.checkOutQuantity = 1;
            _CheckOut.checkOutTax      = 0.04M;
            _CheckOut.checkOutShipping = 10.00M;
            _CheckOut.checkOutDate     = DateTime.Today;

            // map the info
            _cartDataAccess.CreateCart(_mapper.Map(_CheckOut));

            // return to the view products view
            return(RedirectToAction("ViewProducts", "Product"));
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ProductPO GetDataForSave(int id)
        {
            ProductPO item;

            if (id == 0)
            {
                item = new ProductPO()
                {
                    Name = "",
                    Logo = "",
                    ProductcategoryId        = 0,
                    Introduction             = "",
                    MerchantId               = 0,
                    MerchantcustomcategoryId = 0,
                    SchoolId   = 0,
                    Status     = 0,
                    Createtime = DateTime.Now,
                    Updatetime = DateTime.Now,
                };
            }
            else
            {
                item = GetItem(id);
            }
            return(item);
        }
Exemplo n.º 3
0
        public ActionResult UpdateProduct(int productID)
        {
            ProductDO item = null;
            ProductPO display = null;
            ActionResult response = RedirectToAction("Index", "Home");

            //Available to all roles
            if (Session["RoleID"] != null)
            {
                try
                {
                    item = _dataAccess.ReadIndividualProduct(productID);
                    display = ProductMappers.ProductDOtoPO(item);
                }

                catch (Exception exception)
                {
                    ErrorLogger.LogExceptions(exception);
                    response = View(productID);
                }

                finally
                { }

                response = View(display);
            }

            else
            {
                response = RedirectToAction("Index", "Home");
            }

            return response;
        }
Exemplo n.º 4
0
        public ProductTests(TestFixture fixture)
        {
            this.driver = fixture.Driver;

            product = new ProductPO(driver);
            actions = new ActionsHelper(driver);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool Delete(int id)
        {
            var item = new ProductPO {
                Id = id
            };

            return(Delete(item));
        }
Exemplo n.º 6
0
        public ActionResult UpdateProduct(ProductPO productToMap)
        {
            // pass the product through the mapper to the method and then to the DAL
            _productDataAccess.UpdateProduct(_mapper.Map(productToMap));

            // return the user to the list of products
            return(RedirectToAction("ViewProducts"));
        }
Exemplo n.º 7
0
        public SizeAndFitTests(TestFixture fixture)
        {
            this.driver = fixture.Driver;
            tstData     = new SizeAndFitTestsData();

            product = new ProductPO(driver);
            size    = new SizeGuidePO(driver);
            notify  = new NotifyAvailablePO(driver);
        }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Delete(ProductPO item)
 {
     using (var context = new SchoolContext())
     {
         context.Products.Attach(item);
         context.Products.Remove(item);
         context.SaveChanges();
     }
     return(true);
 }
Exemplo n.º 9
0
        public ActionResult CreateProduct(ProductPO productToMap)
        {
            // call the dropdown method to view the possible suppliers
            DropDown();

            // pass the elements of the product to the map through the method call and then to the DAL
            _productDataAccess.AddProduct(_mapper.Map(productToMap));

            // return the user to the view product page
            return(RedirectToAction("ViewProducts"));
        }
        public static ProductPO ProductDOtoPO(ProductDO input)
        {
            ProductPO output = new ProductPO();

            output.ProductID       = input.ProductID;
            output.Name            = input.Name;
            output.TypeOfEquipment = input.TypeOfEquipment;
            output.Manufacturer    = input.Manufacturer;
            output.ModelYear       = input.ModelYear;

            return(output);
        }
Exemplo n.º 11
0
        public static ProductPO MapDoToPo(ProductDO from)
        {
            ProductPO to = new ProductPO();

            to.Name            = from.Name;
            to.CategoryName    = from.CategoryName;
            to.QuantityPerUnit = from.QuantityPerUnit;
            to.UnitPrice       = from.UnitPrice;
            to.UnitsInStock    = from.UnitsInStock;
            to.UnitsOnOrder    = from.UnitsOnOrder;
            to.ReorderLevel    = from.ReorderLevel;
            to.Discontinued    = from.Discontinued;

            return(to);
        }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static bool Save(ProductPO item)
 {
     using (var context = new SchoolContext())
     {
         if (item.Id == 0)
         {
             context.Products.Add(item);
         }
         else
         {
             context.Entry(item).State = EntityState.Modified;
         }
         context.SaveChanges();
     }
     return(true);
 }
Exemplo n.º 13
0
        public static ProductPO DOToPO(ProductDO from)
        {
            ProductPO to = new ProductPO();

            to.ProductId       = from.ProductId;
            to.ProductName     = from.ProductName;
            to.SupplierId      = from.SupplierId;
            to.CatagoryId      = from.CatagoryId;
            to.QuantityPerUnit = from.QuantityPerUnit;
            to.UnitPrice       = from.UnitPrice;
            to.UnitsInStock    = from.UnitsInStock;
            to.UnitsOnOrder    = from.UnitsOnOrder;
            to.ReorderLevel    = from.ReorderLevel;
            to.Discontinued    = from.Discontinued;

            return(to);
        }
Exemplo n.º 14
0
        public static List <ProductPO> MapDOtoPO(List <ProductDO> fromDO)
        {
            List <ProductPO> toPO = new List <ProductPO>();

            try
            {
                foreach (ProductDO data in fromDO)
                {
                    ProductPO mappedData = MapDOtoPO(data);
                    toPO.Add(mappedData);
                }
            }
            catch (Exception)
            {
            }
            return(toPO);
        }
Exemplo n.º 15
0
        public static ProductPO MapDOtoPO(ProductDO fromDO)
        {
            ProductPO toPO = new ProductPO();

            try
            {
                toPO.ProductName     = fromDO.ProductName;
                toPO.QuantityPerUnit = fromDO.QuantityPerUnit;
                toPO.UnitPrice       = fromDO.UnitPrice;
                toPO.UnitsInStock    = fromDO.UnitsInStock;
                toPO.UnitsOnOrder    = fromDO.UnitsOnOrder;
            }
            catch (Exception)
            {
            }
            return(toPO);
        }
Exemplo n.º 16
0
        public ActionResult UpdateProduct(ProductPO form)
        {
            ActionResult response = null;

            //Available to  all roles
            if (Session["RoleID"] != null)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        ProductDO dataObject = ProductMappers.ProductPOtoDO(form);
                        _dataAccess.UpdateProduct(dataObject);
                        response = RedirectToAction("Index", "Product");
                    }

                    catch (Exception exception)
                    {
                        ErrorLogger.LogExceptions(exception);
                        response = View(form);
                    }

                    finally
                    {

                    }
                }

                else
                {
                    response = View(form);
                }
            }

            else
            {
                response = RedirectToAction("Index", "Home");
            }

            return response;
        }
Exemplo n.º 17
0
 public static ProductModel ToModel(this ProductPO item)
 {
     if (item == null)
     {
         return(null);
     }
     return(new ProductModel
     {
         Id = item.Id,
         Name = item.Name,
         Logo = item.Logo,
         ProductcategoryId = item.ProductcategoryId,
         Introduction = item.Introduction,
         MerchantId = item.MerchantId,
         MerchantcustomcategoryId = item.MerchantcustomcategoryId,
         SchoolId = item.SchoolId,
         Status = item.Status,
         Createtime = item.Createtime,
         Updatetime = item.Updatetime,
     });
 }
Exemplo n.º 18
0
        public static List <ProductPO> MapDoListToPo(List <ProductDO> from)
        {
            List <ProductPO> to = new List <ProductPO>();

            foreach (ProductDO item in from)
            {
                ProductPO temp = new ProductPO();

                temp.Name            = item.Name;
                temp.CategoryName    = item.CategoryName;
                temp.QuantityPerUnit = item.QuantityPerUnit;
                temp.UnitPrice       = item.UnitPrice;
                temp.UnitsInStock    = item.UnitsInStock;
                temp.UnitsOnOrder    = item.UnitsOnOrder;
                temp.ReorderLevel    = item.ReorderLevel;
                temp.Discontinued    = item.Discontinued;

                to.Add(temp);
            }

            return(to);
        }