public static BuyingSessionModel NewBuyingSession() { BuyingSessionModel objBuyingSession = new BuyingSessionModel(); objBuyingSession.sessionProductsListlist = new List <ProductModel>(); HttpContext.Current.Session.Add("BuyingSession", objBuyingSession); return(GetBuyingSession()); }
public static bool Delete(int id) { sale_pointEntities db = new sale_pointEntities(); db.produto.Where(x => x.pro_id_produto == id).ToList().ForEach(y => db.produto.Remove(y)); if (BuyingSessionModel.GetBuyingSession().sessionProductsListlist.Any(x => x.productId == id)) { return(false); } return(db.SaveChanges() > 0); }
public static BuyingSessionModel AddProduct(int produtcId) { BuyingSessionModel objBuyingSession = GetBuyingSession(); sale_pointEntities db = new sale_pointEntities(); ProductModel productObj = ProductModel.GetProductModel(produtcId); objBuyingSession.sessionProductsListlist.Add(productObj); objBuyingSession.totalValue += double.Parse(productObj.productPrice); objBuyingSession.totalValue = Math.Round(objBuyingSession.totalValue, 2); return(RecordBuyingSession(objBuyingSession)); }
public static BuyingSessionModel RemoveProduct(int produtcId) { BuyingSessionModel objBuyingSession = GetBuyingSession(); ProductModel productObj = objBuyingSession.sessionProductsListlist.FirstOrDefault(x => x.productId == produtcId); if (productObj != null) { objBuyingSession.sessionProductsListlist.Remove(productObj); objBuyingSession.totalValue -= double.Parse(productObj.productPrice); objBuyingSession.totalValue = Math.Round(objBuyingSession.totalValue, 2); } return(RecordBuyingSession(objBuyingSession)); }
public static BuyingSessionModel RecordBuyingSession(BuyingSessionModel objBuyingSession) { HttpContext.Current.Session["BuyingSession"] = objBuyingSession; return(GetBuyingSession()); }