public ActionResult CustomiseFoodProduct(string Product)
        {
            try
            {
                GbMProduct     foodproductsDetails = new GbMProduct();
                ClsFoodProduct objClsFoodProduct   = new ClsFoodProduct();
                Int64          productId           = 0;
                if (Product != null && Product != string.Empty)
                {
                    try
                    {
                        Int64.TryParse(Product, out productId);
                    }
                    catch (Exception exc)
                    {
                        productId = 0;
                    }
                }
                foodproductsDetails           = objClsFoodProduct.GetProductDetail(productId);
                ViewBag.FoodProductAttributes = objClsFoodProduct.GetProductAttributes(productId, 0);

                #region Get Topping And Other Products
                ViewBag.OtherFoodProducts = objClsFoodProduct.GetProductsByCategories("3,4,6,7,8");
                #endregion

                return(PartialView("CustomiseFoodProduct", foodproductsDetails));
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        /// <summary>
        /// Method to Get Food Product Details
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="categoryId"></param>
        public List <GbMProduct> GetProductList(Int64 productId, int categoryId)
        {
            List <GbMProduct> objGbMProductList = null;

            try
            {
                SqlParameter[] parameter =
                {
                    new SqlParameter("@ProductId",  productId),
                    new SqlParameter("@CategoryId", categoryId),
                };

                using (SqlDataReader rdr = FSC_Helper.ExecuteReader(FSC_Helper.ConnectionStringLocalTransaction,
                                                                    CommandType.StoredProcedure, DBConstant.PROC_PRODUCT_GETLISTOFFOODPRDUCTS
                                                                    , parameter))
                {
                    objGbMProductList = new List <GbMProduct>();
                    while (rdr.Read())
                    {
                        GbMProduct objGbMProduct = new GbMProduct();
                        objGbMProduct.ProductId            = rdr.GetInt64(0);
                        objGbMProduct.CategoryId           = rdr.GetInt32(1);
                        objGbMProduct.CategoryName         = rdr.GetString(2);
                        objGbMProduct.VendorId             = rdr.GetInt32(3);
                        objGbMProduct.VendorName           = rdr.GetString(4);
                        objGbMProduct.ProductName          = rdr.GetString(5);
                        objGbMProduct.ProductDesc          = rdr.GetString(6);
                        objGbMProduct.BasePrice            = rdr.GetDecimal(7);
                        objGbMProduct.BaseCurrencyId       = rdr.GetInt32(8);
                        objGbMProduct.CurrencyName         = rdr.GetString(9);
                        objGbMProduct.VegNonVeg            = rdr.GetString(10);
                        objGbMProduct.ImageURL             = rdr.GetString(11);
                        objGbMProduct.IsAllowedToCustomise = rdr.GetString(12);
                        objGbMProductList.Add(objGbMProduct);
                    }
                }
                return(objGbMProductList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objGbMProductList = null;
            }
        }
        /// <summary>
        /// Method to insert and update Food Product
        /// </summary>
        /// <param name="objGbMProduct"></param>
        public string[] InsUpdFoodProduct(GbMProduct objGbMProduct, DataTable dtProductAttributes)
        {
            try
            {
                SqlParameter[] parameter =
                {
                    new SqlParameter("@ProductId",                  objGbMProduct.ProductId),
                    new SqlParameter("@CategoryId",                 objGbMProduct.CategoryId),
                    new SqlParameter("@VendorId",                   objGbMProduct.VendorId),
                    new SqlParameter("@ProductName",                objGbMProduct.ProductName),
                    new SqlParameter("@ProductDesc",                objGbMProduct.ProductDesc),
                    new SqlParameter("@BasePrice",                  objGbMProduct.BasePrice),
                    new SqlParameter("@BaseCurrencyId",             objGbMProduct.BaseCurrencyId),
                    new SqlParameter("@VegNonVeg",                  objGbMProduct.VegNonVeg),
                    new SqlParameter("@ImageURL",                   objGbMProduct.ImageURL),
                    new SqlParameter("@IsAllowedToCustomise",       objGbMProduct.IsAllowedToCustomise),
                    new SqlParameter("@Udt_FoodProduct_Attributes", dtProductAttributes),
                    new SqlParameter("@IsActive",                   objGbMProduct.IsActive),
                    new SqlParameter("@CrtBy",                      objGbMProduct.CrtBy),
                    new SqlParameter("@CrtIP",                      objGbMProduct.CrtIp),
                    new SqlParameter("@ErrorMsg",                   SqlDbType.VarChar, 50)
                    {
                        Direction = ParameterDirection.Output
                    },
                    new SqlParameter("@ErrorDesc",                  SqlDbType.VarChar, 500)
                    {
                        Direction = ParameterDirection.Output
                    }
                };

                return(FSC_Helper.ExecuteNonQueryOutputResult(FSC_Helper.ConnectionStringLocalTransaction,
                                                              CommandType.StoredProcedure, DBConstant.PROC_PRODUCT_INSUPDFOODPRODUCT, new string[] { "@ErrorMsg", "@ErrorDesc" }, parameter));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult FoodItemIU(string product)
        {
            try
            {
                Int64      productId         = 0;
                GbMProduct objProductDetails = new GbMProduct();

                if (product != null && product != string.Empty)
                {
                    try
                    {
                        Int64.TryParse(product, out productId);
                    }
                    catch (Exception exc)
                    {
                        productId = 0;
                    }
                }
                if (productId > 0)
                {
                    ViewBag.Title     = "Edit Food Item";
                    objProductDetails = new ClsFoodProduct().GetProductDetail(productId);
                }
                else
                {
                    ViewBag.Title = "Add Food Item";
                }
                GetFoodProductViewBagData(productId, objProductDetails.CategoryId);

                return(View("FoodItemIU", objProductDetails));
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
示例#5
0
        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));
        }
        /// <summary>
        /// Method to Get Food Product List
        /// </summary>
        public object GetFoodProducts(DataTablesRequest request)
        {
            List <GbMProduct> objListGbMProduct = new List <GbMProduct>();

            try
            {
                var startPage = (request.DisplayLength == 0) ? 1 : request.DisplayStart / request.DisplayLength + 1;

                var orderBy = string.Join(",", DTHelper.GetOrderByClause(request));

                int skip = (startPage - 1) * request.DisplayLength;

                int take = skip + request.DisplayLength;

                int TotalItems = 0;


                SqlParameter[] parameter =
                {
                    new SqlParameter("@CategoryId", request.CategoryId),
                    new SqlParameter("@VendorId",   request.VendorId),
                    new SqlParameter("@Start",      skip),
                    new SqlParameter("@End",        take),
                    new SqlParameter("@Search",     request.Search),
                    new SqlParameter("@OrderBy",    orderBy),
                };

                using (SqlDataReader rdr = FSC_Helper.ExecuteReader(FSC_Helper.ConnectionStringLocalTransaction,
                                                                    CommandType.StoredProcedure, DBConstant.PROC_PRODUCT_GETFOODPRDUCTS, parameter))
                {
                    while (rdr.Read())
                    {
                        if (rdr["Count"] != DBNull.Value)
                        {
                            TotalItems = Convert.ToInt32(rdr["Count"]);
                        }

                        rdr.NextResult();

                        while (rdr.Read())
                        {
                            GbMProduct objGbMProduct = new GbMProduct();
                            objGbMProduct.ProductId     = rdr.GetInt64(1);
                            objGbMProduct.VendorName    = rdr.GetString(2);
                            objGbMProduct.CategoryName  = rdr.GetString(3);
                            objGbMProduct.ProductName   = rdr.GetString(4);
                            objGbMProduct.ProductDesc   = rdr.GetString(5);
                            objGbMProduct.BasePriceDesc = rdr.GetString(6);
                            objListGbMProduct.Add(objGbMProduct);
                        }
                    }
                }

                return(new
                {
                    sEcho = request.Echo,
                    iTotalRecords = TotalItems,
                    iTotalDisplayRecords = TotalItems,
                    sColumns = request.ColumnNames,
                    aaData = (from i in objListGbMProduct
                              select new[]
                    {
                        Convert.ToString(i.ProductId),
                        Convert.ToString(i.ProductName),
                        Convert.ToString(i.ProductDesc),
                        Convert.ToString(i.BasePriceDesc),
                        Convert.ToString(i.CategoryName),
                        Convert.ToString(i.VendorName)
                    }).ToList()
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objListGbMProduct = null;
            }
        }