Ejemplo n.º 1
0
        public string LoadProducts()
        {
            PLog.Info("BEGIN::Controller > Home, Method > LoadProducts()");

            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();

            try
            {
                IProductsImple oProductsImple = new ProductsImple();

                DataTable dt = oProductsImple.GetGridData(0); //0 will gets all the products data


                Dictionary <string, object> row;
                foreach (DataRow dr in dt.Rows)
                {
                    row = new Dictionary <string, object>();
                    foreach (DataColumn col in dt.Columns)
                    {
                        row.Add(col.ColumnName, dr[col]);
                    }
                    rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Controller > Home, Method > LoadProducts()", ex);
            }
            PLog.Info("END::Controller > Home, Method > LoadProducts()");
            return(serializer.Serialize(rows));
        }
Ejemplo n.º 2
0
        public long DeleteProduct(string ID)
        {
            PLog.Info("BEGIN::Controller > Home, Method > DeleteProduct(string ID)");
            long ret = 0;

            if (!string.IsNullOrEmpty(ID))
            {
                try
                {
                    IProductsImple oProductsImple = new ProductsImple();
                    ret = oProductsImple.DeleteProduct(Convert.ToInt32(ID));
                }
                catch (Exception ex)
                {
                    PLog.Error("Error::Controller > Home, Method > DeleteProduct(string ID)", ex);
                }
            }
            PLog.Info("END::Controller > Home, Method > DeleteProduct(string ID)");
            return(ret);
        }
Ejemplo n.º 3
0
        public ActionResult UpdateProduct(string ID)
        {
            PLog.Info("BEGIN::Controller > Home, Method > UpdateProduct(string ID");
            IProductsImple oProductsImple = new ProductsImple();
            ProductsModel  objModel       = null;

            try
            {
                if (!string.IsNullOrEmpty(ID))
                {
                    objModel = oProductsImple.EditProdcut(Convert.ToInt32(ID));
                }
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Controller > Home, Method > UpdateProduct(string ID)", ex);
            }
            PLog.Info("END::Controller > Home, Method > UpdateProduct(string ID)");
            return(View("Products", objModel));
        }
Ejemplo n.º 4
0
        public ActionResult SaveProduct(string Data)
        {
            PLog.Info("BEGIN::Controller > Home, Method > SaveProduct(string Data)");
            long           flg            = 0;
            IProductsImple oProductsImple = new ProductsImple();

            try
            {
                ProductsModel obj  = JsonConvert.DeserializeObject <ProductsModel>(Data);
                string[]      date = obj.efDate.Split('-');
                obj.efDate = new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0])).ToString();
                flg        = oProductsImple.SaveProducts(obj);
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Controller > Home, Method > SaveProduct(string Data)", ex);
            }
            PLog.Info("END::Controller > Home, Method > SaveProduct(string Data)");
            return(Content(flg.ToString()));
        }