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")); }
/// <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); }
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; }
public ProductTests(TestFixture fixture) { this.driver = fixture.Driver; product = new ProductPO(driver); actions = new ActionsHelper(driver); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(int id) { var item = new ProductPO { Id = id }; return(Delete(item)); }
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")); }
public SizeAndFitTests(TestFixture fixture) { this.driver = fixture.Driver; tstData = new SizeAndFitTestsData(); product = new ProductPO(driver); size = new SizeGuidePO(driver); notify = new NotifyAvailablePO(driver); }
/// <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); }
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); }
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); }
/// <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); }
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); }
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); }
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); }
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; }
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, }); }
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); }