public ActionResult SaveProduct(SA_Product UserProduct)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    var path = Path.Combine(Server.MapPath("~/ProductImages"), fileName);
                    file.SaveAs(path);
                    UserProduct.ProductImg = fileName;
                }
            }
            UserProduct.CreatedTime = DateTime.Now;
            ProductDataStore Obj = new ProductDataStore();

            if (UserProduct.id == 0)
            {
                Obj.AddProduct(UserProduct);
            }
            else
            {
                Obj.EditProduct(UserProduct);
            }
            return(RedirectToAction("Product"));
        }
        public ActionResult UpdateStatus(int productId)
        {
            ProductDataStore Obj = new ProductDataStore();

            Obj.UpdateStatus(productId);
            return(RedirectToAction("GetProductList"));
        }
Exemplo n.º 3
0
        public ActionResult DealsHome(int?page)
        {
            //int pageSize = 6;
            //DealsDataStore d = new DealsDataStore();
            //var model= d.GetDealsList().ToPagedList(page ?? 1, pageSize);
            //return View(model);
            NewsDataStore nc = new NewsDataStore();

            ViewBag.f = nc.GetFirstProduct();
            int                pageSize = 6;
            DealsDataStore     n        = new DealsDataStore();
            ProductDataStore   p        = new ProductDataStore();
            DealsHomeViewModel model    = new DealsHomeViewModel();

            if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER")
            {
                model.DealsList = n.GetCustDealsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize);
            }

            else
            {
                model.DealsList = n.GetDealsList().ToPagedList(page ?? 1, pageSize);
            }

            ViewBag.f        = n.GetFirstProduct();
            ViewBag.category = p.ProductList();
            return(View(model));
        }
        public ActionResult Product()
        {
            ProductDataStore Obj = new ProductDataStore();

            //List<SA_Product> ProductList = Obj.GetProductList();
            return(View("Product"));
        }
        public ActionResult ProductList(string id, string search)
        {
            NewsDataStore        Obj      = new NewsDataStore();
            DealsDataStore       d        = new DealsDataStore();
            ProductListViewModel model    = new ProductListViewModel();
            List <SA_News>       NewsList = Obj.GetNewsList();

            model.NewsList = NewsList;
            List <SA_Deals> DealList = d.GetDealsList();

            model.DealsList = DealList;
            ProductDataStore        p           = new ProductDataStore();
            IQueryable <SA_Product> ProductList = p.GetProductListBySearch(id, search);

            model.ProductList = ProductList;
            CategoryDataStore c = new CategoryDataStore();

            if (id != "")
            {
                var categoryName = c.GetCategoryByid(Convert.ToInt32(id));
                ViewBag.CategoryName = categoryName.CategoryName;
            }
            else
            {
                ViewBag.CategoryName = "";
            }

            ViewBag.category = c.CategoryList();
            return(View("~/Views/ChemAnalyst/products.cshtml", model));
        }
Exemplo n.º 6
0
        public ActionResult DealsHome(int?page, string id, DateTime?search, DateTime?searchto, string keyword)
        {
            ViewBag.formdate = search != null?Convert.ToDateTime(search).ToString("MM/dd/yyyy") : "";

            ViewBag.todate = searchto != null?Convert.ToDateTime(searchto).ToString("MM/dd/yyyy") : "";

            int           pageSize = 6;
            NewsDataStore nc       = new NewsDataStore();

            ViewBag.f = nc.GetFirstProduct();
            DealsDataStore     n     = new DealsDataStore();
            ProductDataStore   p     = new ProductDataStore();
            DealsHomeViewModel model = new DealsHomeViewModel();

            if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER")
            {
                model.DealsList = n.GetDealsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize);
                //model.DealsList = n.GetCustDealsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize);
            }

            else
            {
                model.DealsList = n.GetDealsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize);
            }
            ViewBag.category = p.ProductList();
            return(View(model));
        }
Exemplo n.º 7
0
        public void GlobalSetup()
        {
            string endpointUrl = ConfigurationManager.AppSettings["DocumentDBEndpoint"];
            string primaryKey  = ConfigurationManager.AppSettings["DocumentDBPrimaryKey"];

            this._productDataStore = new ProductDataStore(endpointUrl, primaryKey);
            this._productDataStore.CreateDocumentCollection("empty_collection").Wait();

            TestData.SetUpDBWithTestData(this._productDataStore, this._collectionName);
        }
Exemplo n.º 8
0
        public void GlobalSetup()
        {
            string EndpointUrl = ConfigurationManager.AppSettings["DocumentDBEndpoint"];
            string PrimaryKey  = ConfigurationManager.AppSettings["DocumentDBPrimaryKey"];

            this._productDataStore = new ProductDataStore(EndpointUrl, PrimaryKey);
            this._telemetryLogger  = new Mock <ITelemetryLogger>();
            this._controller       = new ProductController(this._productDataStore);

            this._productDataStore.CreateDocumentCollection("empty_collection");

            TestData.TestData.SetUpDBWithTestData(this._productDataStore, this._collectionName);
        }
        public ActionResult DeleteProduct(int id)
        {
            ProductDataStore Obj = new ProductDataStore();

            if (Obj.DeleteProduct(id) == true)
            {
                //return View("Product");
                return(RedirectToAction("Product"));
            }
            else
            {
                return(View("ErrorEventArgs"));
            }
        }
        public JsonResult ProductList4AddPkg()
        {
            ProductDataStore   Obj      = new ProductDataStore();
            ChemAnalystContext _context = new ChemAnalystContext();
            var list = (from product in _context.SA_Product
                        //join category in _context.SA_Category on product.Category equals category.id
                        select new
            {
                //ProductDiscription = category.CategoryName,
                ProductName = product.ProductName,
                CreatedTime = product.CreatedTime,
                id = product.id,
                status = product.status,
            }).ToList();

            return(Json(new { data = list }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult EditProduct(int id)
        {
            ProductDataStore Obj = new ProductDataStore();
            SA_Product       obj = Obj.GetProductByid(id);

            CategoryDataStore     Objcat       = new CategoryDataStore();
            List <SelectListItem> CategoryList = Objcat.CategoryList();
            SA_ProductViewModel   objSaCatV    = new SA_ProductViewModel();

            objSaCatV.id                 = obj.id;
            objSaCatV.ProductName        = obj.ProductName;
            objSaCatV.ProductDiscription = obj.ProductDiscription;
            objSaCatV.Meta               = obj.Meta;
            objSaCatV.MetaDiscription    = obj.MetaDiscription;
            objSaCatV.CategoryList       = CategoryList;
            objSaCatV.Category           = obj.Category.ToString();

            return(View("add-Product", objSaCatV));
        }
Exemplo n.º 12
0
        public JsonResult GetCustIndustryList()
        {
            var LoginUser = Convert.ToInt32(Session["LoginUser"]);
            ProductDataStore ObjProduct = new ProductDataStore();

            //var custProduct = ObjProduct.GetCustProductList(LoginUser);
            List <string> custProduct = ObjProduct.GetCustProductList(LoginUser);

            IndustryDataStore Obj = new IndustryDataStore();
            var IndustryList      = Obj.GetCustIndustryList(custProduct).Select(w => new IndustryVM
            {
                id         = w.id,
                Title      = w.Title,
                CreateTime = w.CreatedTime != null ? w.CreatedTime.Value.ToString("dd/MM/yyyy") : "",
                Product    = w.Product != null ? ObjProduct.GetProductByid(w.Product).ProductName : "",
            });;

            return(Json(new { data = IndustryList }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
 public ActionResult LoadIndustryData()
 {
     try
     {
         ProductDataStore  ObjProduct = new ProductDataStore();
         IndustryDataStore Obj        = new IndustryDataStore();
         var IndustryList             = Obj.GetIndustryList().Select(w => new IndustryVM
         {
             id         = w.id,
             Title      = w.Title,
             CreateTime = w.CreatedTime != null ? w.CreatedTime.Value.ToString("dd/MM/yyyy") : "",
             Product    = w.Product != null ? ObjProduct.GetProductByid(w.Product).ProductName : "",
         });
         return(Json(new { data = IndustryList }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult ProductList()
        {
            NewsDataStore        Obj      = new NewsDataStore();
            DealsDataStore       d        = new DealsDataStore();
            ProductListViewModel model    = new ProductListViewModel();
            List <SA_News>       NewsList = Obj.GetNewsList();

            model.NewsList = NewsList;
            List <SA_Deals> DealList = d.GetDealsList();

            model.DealsList = DealList;
            ProductDataStore  p           = new ProductDataStore();
            List <SA_Product> ProductList = p.GetProductList();

            model.ProductList = ProductList;
            CategoryDataStore c = new CategoryDataStore();

            ViewBag.category = c.CategoryList();
            return(View("~/Views/ChemAnalyst/products.cshtml", model));
        }
Exemplo n.º 15
0
        public ActionResult NewsHome(int?page)
        {
            int               pageSize = 6;
            NewsDataStore     n        = new NewsDataStore();
            ProductDataStore  p        = new ProductDataStore();
            NewsHomeViewModel model    = new NewsHomeViewModel();

            //ViewBag.formdate = new DateTime(DateTime.Now.Year,DateTime.Now.Month,01).ToString("MM/dd/yyyy");
            //ViewBag.todate = DateTime.Now.ToString("MM/dd/yyyy");
            if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER")
            {
                model.NewsList = n.GetCustNewsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize);
            }

            else
            {
                model.NewsList = n.GetNewsList().ToPagedList(page ?? 1, pageSize);
            }
            ViewBag.category = p.ProductList();
            return(View(model));
        }
Exemplo n.º 16
0
        private async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;
            try
            {
                Items.Clear();
                var items = await ProductDataStore.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public ActionResult DeleteCategory(int id)
        {
            CategoryDataStore Obj = new CategoryDataStore();
            // check if this category is in product
            ProductDataStore ObjProd = new ProductDataStore();

            if (ObjProd.CheckCategory(id))
            {
                TempData["ErrorMessage"] = "You can not delete this category, please delete related product first.";
                return(RedirectToAction("Category"));
            }
            else
            {
                if (Obj.DeleteCategory(id) == true)
                {
                    //return View("Category");
                    return(RedirectToAction("Category"));
                }
                else
                {
                    return(View("ErrorEventArgs"));
                }
            }
        }