public JsonResult AddToCart(string jsonProduct, string jsonTopping) { ProductCart objProduct = null; List <ProductCartToppings> objProductCartToppings = null; List <KeyValuePair <string, string> > objStatus = null; string MsgType = "Error"; string Msg = string.Empty; try { objProduct = (ClsWebCommon.JsonDeserialize <ProductCart>(jsonProduct)) as ProductCart; objProductCartToppings = new List <ProductCartToppings>(); if (jsonTopping != "" && jsonTopping != null) { objProductCartToppings = (ClsWebCommon.JsonDeserialize <List <ProductCartToppings> >(jsonTopping)) as List <ProductCartToppings>; } if (objProduct.ProductId > 0) { objProduct.SessionId = SessionManager.GetSessionId(); if (objProductCartToppings != null && objProductCartToppings.Count > 0) { objProduct.Toppings = objProductCartToppings; } List <ProductCart> objCurrentSessionCart = SessionManager.GetCartSession(); if (objCurrentSessionCart != null && objCurrentSessionCart.Count > 0) { objCurrentSessionCart.Add(objProduct); } else { objCurrentSessionCart = new List <ProductCart>(); objCurrentSessionCart.Add(objProduct); } SessionManager.SetCartSession(objCurrentSessionCart); Msg = "Product Added To Cart!"; MsgType = "Success"; } else { Msg = "Error!"; } objStatus = new List <KeyValuePair <string, string> >(); objStatus.Add(new KeyValuePair <string, string>("MsgType", MsgType)); objStatus.Add(new KeyValuePair <string, string>("Msg", Msg)); } catch (Exception ex) { objStatus = new List <KeyValuePair <string, string> >(); objStatus.Add(new KeyValuePair <string, string>("MsgType", MsgType)); objStatus.Add(new KeyValuePair <string, string>("Msg", "Error")); throw ex; } return(Json(objStatus)); }
// GET: FoodItem Item List public ActionResult ManageFoodItem() { try { ViewBag.Title = "Food Products"; if (Request.Form["hdMsg"] != null) { Message objMessage = new Message(); objMessage = (ClsWebCommon.JsonDeserialize <Message>(Request.Form["hdMsg"])) as Message; @ViewBag.Msg = objMessage.Msg; @ViewBag.MsgType = objMessage.MsgType; } ViewBag.VendorsFoodProductWL = new SelectList(new ClsCommon().GetVendors(0), "VendorId", "VendorName"); ViewBag.CategoryFoodProductWL = new SelectList(new ClsCommon().GetCategory(0), "CategoryId", "CategoryName"); return(View("ManageFoodItem")); } catch (Exception exc) { throw exc; } }
public JsonResult InsUpdFoodProduct(string jsonProduct, string jsonProductDetails) { GbMProduct objProduct = null; List <KeyValuePair <string, string> > objStatus = null; List <GbMProductAttribute> listProductAttributes = null; string MsgType = "Error"; string Msg = string.Empty; try { string strDateValidation = string.Empty; objProduct = (ClsWebCommon.JsonDeserialize <GbMProduct>(jsonProduct)) as GbMProduct; DataTable dtProductAttributeDetails = GetProductAttributeTable(); if (objProduct.IsActive == "Y") { #region Food Product Detail listProductAttributes = new List <GbMProductAttribute>(); if (jsonProductDetails != "" && jsonProductDetails != null) { listProductAttributes = (ClsWebCommon.JsonDeserialize <List <GbMProductAttribute> >(jsonProductDetails)) as List <GbMProductAttribute>; } #region Get Product Attributes Datatble DataRow dr = null; foreach (GbMProductAttribute attributes in listProductAttributes) { dr = dtProductAttributeDetails.NewRow(); dr["BasePrice"] = attributes.BasePrice; dr["AttributeId1"] = attributes.AttributeId1; dr["AttributeId2"] = attributes.AttributeId2; dr["AttributeId3"] = attributes.AttributeId3; dr["AttributeId4"] = attributes.AttributeId4; dr["AttributeId5"] = attributes.AttributeId5; dr["AttributeId6"] = attributes.AttributeId6; dr["AttributeId7"] = attributes.AttributeId7; dr["AttributeId8"] = attributes.AttributeId8; dr["AttributeId9"] = attributes.AttributeId9; dr["AttributeId10"] = attributes.AttributeId10; dr["IsDefault"] = attributes.IsDefault; dr["IsActive"] = attributes.IsActive; dtProductAttributeDetails.Rows.Add(dr); } #endregion #endregion } #region Ins Upd Food Product if (strDateValidation == string.Empty) { objProduct.CrtBy = GetSession.GetSessionFromContext().UserId; objProduct.CrtIp = FSCSecurity.GetIPAddress(); string[] Out = new ClsFoodProduct().InsUpdFoodProduct(objProduct, dtProductAttributeDetails); if (Out[0] != string.Empty) { switch (Out[0]) { case CodeConstant.Code_InsertSuccess: case CodeConstant.Code_UpdateSuccess: case CodeConstant.Code_DeleteSuccess: MsgType = "Success"; Msg = HttpContext.GetGlobalResourceObject("AdminPanel", "FoodProduct_" + Out[0]).ToString(); break; case CodeConstant.Code_FOOD_ITEM_NAME_DUPLICATE: case CodeConstant.Code_FOOD_ITEM_ATTRIBUTE_MANDATORY: case CodeConstant.Code_FOOD_PRODUCT_ATTRIBUTE_NOT_EXISTS: Msg = HttpContext.GetGlobalResourceObject("AdminPanel", "FoodProduct_" + Out[0]).ToString(); break; default: Msg = HttpContext.GetGlobalResourceObject("AdminPanel", "T1100").ToString(); break; } } else { Msg = HttpContext.GetGlobalResourceObject("AdminPanel", "T1100").ToString(); } } else { Msg = strDateValidation; } #endregion objStatus = new List <KeyValuePair <string, string> >(); objStatus.Add(new KeyValuePair <string, string>("MsgType", MsgType)); objStatus.Add(new KeyValuePair <string, string>("Msg", Msg)); } catch (Exception ex) { objStatus = new List <KeyValuePair <string, string> >(); objStatus.Add(new KeyValuePair <string, string>("MsgType", MsgType)); Msg = HttpContext.GetGlobalResourceObject("AdminPanel", "T1100").ToString(); objStatus.Add(new KeyValuePair <string, string>("Msg", Msg)); throw ex; } return(Json(objStatus)); }