示例#1
0
        public ActionResult Home()

        {
            List <SW.Entities.ProductDTO> list = ProductBO.getProducts();

            return(View(list));
        }
示例#2
0
        public IEnumerable GetAvailableProducts(string currentUser)
        {
            try
            {
                ObjectCache cache = MemoryCache.Default;
                if (cache.Contains(cacheKey))
                {
                    return((IEnumerable)cache.Get(cacheKey));
                }
                else
                {
                    IProduct    productBO       = new ProductBO(currentUser);
                    IEnumerable availableStocks = productBO.GetAllProducts();// this.GetDefaultStocks();

                    // Store data in the cache
                    CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
                    cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddHours(6);
                    cache.Add(cacheKey, availableStocks, cacheItemPolicy);

                    return(availableStocks);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#3
0
        public ActionResult DisplayAllItems(string category)
        {
            List <SW.Entities.ProductDTO> list = ProductBO.getProducts(category);

            ViewBag.Name = category;
            return(View(list));
        }
示例#4
0
        public Product Update(Product obj)
        {
            ProductBO infrastructureBO = new ProductBO(obj);

            productDao.Update(infrastructureBO);
            return(obj);
        }
        public ActionResult UpdateProduct(int id = 0)
        {
            ProductBO model = new ProductBO();

            ViewBag.ProductType = 0;
            if (id > 0)
            {
                model = ProductDAO.GetProductByID(id);
                if (model == null)
                {
                    return(RedirectToAction("Index"));
                }
                if (model.collectionid > 0)
                {
                    ViewBag.ProductType = 1;
                }
                else
                {
                    ViewBag.ProductType = 2;
                }
            }

            InitSelectListCollection();
            InitSelectListPhoneModel();
            return(View(model));
        }
示例#6
0
        public ActionResult Category(string id)
        {
            ProductBO productBO = new ProductBO();

            ViewBag.Category = id;
            return(View(productBO.GetProductsByCategory(id)));
        }
        public IActionResult Get(long id)
        {
            ProductBO    productBO;
            Product      product;
            ObjectResult response;

            try
            {
                _log.LogInformation($"Starting Get( {id} )");

                productBO = new ProductBO(_loggerFactory, _config);

                product = productBO.Get(id);

                if (product != null)
                {
                    response = Ok(product);
                }
                else
                {
                    response = NotFound(string.Empty);
                }

                _log.LogInformation($"Finishing Get( {id} )");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }
示例#8
0
        public int AddProduct(ProductBO product)
        {
            try
            {
                List <ProductDescription> descr = new List <ProductDescription>();
                Product prod = new Product();
                prod.ProductName        = product.ProductName;
                prod.ProductDescription = product.ProductDescription;
                foreach (var item in product.DescriptionBO)
                {
                    ProductDescription desc = new ProductDescription();
                    desc.Size        = item.Size;
                    desc.UnitPrice   = item.UnitPrice;
                    desc.QualityType = item.QualityType;
                    desc.Discount    = item.Discount;
                    descr.Add(desc);
                }
                prod.ProductDescriptions = descr;
                _db.Products.Add(prod);
                _db.SaveChanges();
                return(prod.ProductID);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IActionResult Get(long?code = null, string name = null, int?categoryID = null, int?categoryDetailID = null)
        {
            ProductBO      productBO;
            List <Product> products;
            ObjectResult   response;

            try
            {
                _log.LogInformation("Starting Get()");

                productBO = new ProductBO(_loggerFactory, _config);
                products  = productBO.Get(code: code, name: name, categoryID: categoryID, categoryDetailID: categoryDetailID);

                response = Ok(products);

                _log.LogInformation($"Finishing Get() with '{products.Count}' results");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }
示例#10
0
        /// <summary>
        /// Get a product with reviews and ratings
        /// </summary>
        /// <param name="id">Product id</param>
        /// <returns>DTO of Product with Reviews and Average rating</returns>
        public AlzaAdminDTO <ProductBO> GetProduct(int id)
        {
            try
            {
                //gets the base product with no reviews and ratings
                var baseProduct = _productRepository.GetProduct(id);

                //if the product was not found, it cannot be joined with any ratings
                if (ReferenceEquals(baseProduct, null))
                {
                    return(AlzaAdminDTO <ProductBO> .Data(null));
                }

                //average rating of the product
                var avRating = _productRatingRepository.GetRating(id);

                //get product reviews and users who submitted the reviews
                var reviews = _reviewRepository.GetReviews().Where(r => r.ProductId == id).ToList();
                var users   = _userProfileRepository.GetAllProfiles().Where(p => reviews.Select(r => r.UserId).Contains(p.Id));
                reviews = reviews.Join(users, r => r.UserId, p => p.Id, (r, p) => { r.User = p; return(r); }).OrderBy(r => r.Date).ToList();
                var product = new ProductBO(baseProduct, avRating, reviews);

                return(AlzaAdminDTO <ProductBO> .Data(product));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <ProductBO> .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
        public bool UpdateProduct(long productoId, ProductBO product)
        {
            var success = false;

            if (product != null)
            {
                using (var scope = new TransactionScope())
                {
                    var productoEncontrado = _unitOfWork.ProductosRepositorio.ObtenerPorId(productoId);

                    if (productoEncontrado != null)
                    {
                        productoEncontrado.Name             = product.Name;
                        productoEncontrado.PrecioAlPorMenor = product.PrecioAlPorMenor;
                        productoEncontrado.PrecioCompra     = product.PrecioCompra;

                        _unitOfWork.ProductosRepositorio.Actualizar(productoEncontrado);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }

            return(success);
        }
示例#12
0
        public ActionResult Delete(ProductBO product, int id)
        {
            int del = id - 1;

            product.DescriptionBO.RemoveAt(del);
            return(PartialView("Descript", product));
        }
示例#13
0
 public ActionResult Details(long i)
 {
     ProductBO cls = new ProductBO();
     var model = cls.GetProduct(i);
     _session.IsLogin = false;
     return View(model);
 }
示例#14
0
        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            products.CurrentPageIndex = e.NewPageIndex;

            // Get the search terms from the query string
            string searchKey = WebComponents.CleanString.InputText(Request["keywords"], 100);

            if (searchKey != "")
            {
                // Create a data cache key
                string cacheKey = "search" + searchKey;

                // Check if the objects are in the cache
                if (Cache[cacheKey] != null)
                {
                    products.DataSource = (IList)Cache[cacheKey];
                }
                else
                {
                    // If that data is not in the cache then use the business logic tier to fetch the data
                    ProductBO           product          = new ProductBO();
                    IList <ProductInfo> productsBySearch = product.GetProductsBySearch(searchKey);
                    // Store the results in a cache
                    Cache.Add(cacheKey, productsBySearch, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
                    products.DataSource = productsBySearch;
                }

                // Databind the data to the controls
                products.DataBind();
            }
        }
    public void GetProducts()
    {
        DataSet ds  = new DataSet();
        string  qry = "select PM.Record_Id as Product_Id,PM.Product_Code,PM.Product_Name,PTM.Product_Type from dbo.Tbl_Product_Master PM join dbo.Tbl_Product_Type_Master PTM on PTM.Record_Id=PM.Product_Category_Id where PM.Is_Del=0 and PM.Is_Active=1";

        ds = ObjCommon.GetObject.ExecuteQuery_Select(Connection.ConnectionString, qry);

        DataTable testTable = new DataTable();

        testTable = ds.Tables[0];

        testCollection = new ObservableCollection <ProductBO>();

        foreach (DataRow row in testTable.Rows)
        {
            var obj = new ProductBO()
            {
                Product_Code = (string)row["Product_Code"],
                ProductNo    = (int)row["ProductNo "]
            };
            testCollection.Add(obj);
        }

        this.OnPropertyChanged("TestCollection");
    }
        public IActionResult Put(long id, [FromBody] Product product)
        {
            ProductBO    productBO;
            ObjectResult response;

            try
            {
                _log.LogInformation($"Starting Put( {id}, '{JsonConvert.SerializeObject(product, Formatting.None)}')");

                productBO = new ProductBO(_loggerFactory, _config);

                product.ID = id;
                product    = productBO.Update(product);

                response = Ok(product);

                _log.LogInformation($"Finishing Put( {id} )");
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                response = StatusCode(500, ex.Message);
            }

            return(response);
        }
示例#17
0
        private void textBoxBarCode_TextChanged(object sender, EventArgs e)
        {
            string strBarCode = textBoxBarCode.Text;

            if (!string.IsNullOrEmpty(strBarCode) && strBarCode.Length > 3)
            {
                var curoutputdetail = lstOutputVoucer.SingleOrDefault(p => p.ProductID == strBarCode);
                if (curoutputdetail != null)
                {
                    ProductBO objProductBO = new ProductDAO().getproductbybarcode(strBarCode);

                    if (objProductBO != null)
                    {
                        labelProductName.Text = objProductBO.ProductName + " Sl mua: " + curoutputdetail.Quantity;
                        objCurProduct         = objProductBO;
                    }
                    else
                    {
                        labelProductName.Text = "";
                        objCurProduct         = null;
                    }
                }
                else
                {
                    labelProductName.Text = "";
                    objCurProduct         = null;
                }
            }
            else
            {
                labelProductName.Text = "";
                objCurProduct         = null;
            }
        }
示例#18
0
        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            products.CurrentPageIndex = e.NewPageIndex;

            // Get the category from the query string
            // string categoryKey = Request["categoryId"];
            string categoryKey = WebComponents.CleanString.InputText(Request["categoryId"], 50);

            // Check to see if the contents are in the Data Cache
            if (Cache[categoryKey] != null)
            {
                // If the data is already cached, then used the cached copy
                products.DataSource = (IList)Cache[categoryKey];
            }
            else
            {
                // If the data is not cached, then create a new products object and request the data
                ProductBO           product            = new ProductBO();
                IList <ProductInfo> productsByCategory = product.GetProductsByCategory(categoryKey);
                // Store the results of the call in the Cache and set the time out to 12 hours
                Cache.Add(categoryKey, productsByCategory, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
                products.DataSource = productsByCategory;
            }

            // Bind the data to the control
            products.DataBind();
            // Set the label to be the query parameter
            lblPage.Text = categoryKey;
        }
示例#19
0
        public JsonResult SaveProduct(Product product)
        {
            ProductBO cls      = new ProductBO();
            bool      IsResult = cls.Save(product);

            return(Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet));
        }
示例#20
0
 public ActionResult CreateProduct(int id)
 {
     ViewBag.ID = id;
     if (_session.IsLogin)
     {
         Product model = new Product();
         if (id != -1)
         {
             ProductBO cls = new ProductBO();
             model = cls.GetByID(id);
             if (model == null)
             {
                 model = new Product();
             }
             ViewBag.Image      = model.ImageThumbnail;
             ViewBag.ImageLarge = model.ImageLarge;
             return(View(model));
         }
         else
         {
             return(View(model));
         }
     }
     else
     {
         return(RedirectToAction("index", "admin"));
     }
 }
示例#21
0
        public ActionResult RealProductAtWaduCase(ProductBO objProduct)
        {
            int id = 3;

            List <RealCaseBO> lstRealCase = CollectionDAO.GetListRealCaseByCollectionID(id, 8);

            return(PartialView(lstRealCase));
        }
示例#22
0
        private ProductBO GetProductById(int id)
        {
            ProductService productService = new ProductService();
            IRestResponse  response       = productService.GetProduct($"http://apib2c/api/Product/{id}", Method.GET);
            ProductBO      product        = JsonConvert.DeserializeObject <ProductBO>(response.Content);

            return(product);
        }
示例#23
0
        public ActionResult ProductDescription()
        {
            ProductBO            product     = new ProductBO();
            List <DescriptionBO> description = new List <DescriptionBO>();

            product.DescriptionBO = description;
            return(PartialView("Descript", product));
        }
 public IActionResult Post([FromBody] ProductBO product)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     return(Ok(facade.ProductService.Create(product)));
 }
示例#25
0
        public ActionResult Details(long i)
        {
            ProductBO cls   = new ProductBO();
            var       model = cls.GetProduct(i);

            _session.IsLogin = false;
            return(View(model));
        }
示例#26
0
 public ProductBO Create(ProductBO product)
 {
     using (var uow = facade.UnitOfWork)
     {
         newProduct = uow.ProductRepository.Create(prodConv.Convert(product));
         uow.Complete();
         return prodConv.Convert(newProduct);
     }
 }
示例#27
0
        //
        // GET: /Product/

        public ActionResult Index(int ? p)
        {
            ProductBO cls = new ProductBO();
            var model = cls.GetData();
            _session.IsLogin = false;
            int pageSize = 9;
            int pageNumber = (p ?? 1);
            return View(model.ToPagedList(pageNumber, pageSize));
        }
        public void AddProductBL(string ProductName)
        {
            ProductBO objProductBO = new ProductBO();

            objProductBO.ProductName = ProductName;
            ProductDA objProductDA = new ProductDA();

            objProductDA.AddProductDA(objProductBO);
        }
示例#29
0
        public ProductCard(int proId)
        {
            pbo    = new ProductBO();
            iProID = proId;
            Product p = pbo.GetProductbyId(proId);

            sProName  = p.ProductName;
            dPrice    = (decimal)p.UnitPrice;
            iQuantity = 1;
        }
示例#30
0
        public ActionResult Wishlist(string c_id)
        {
            List <int>        Products_list = ProductBO.getProductsOfCustomerInWishlist(Convert.ToInt32(c_id));
            List <ProductDTO> list          = new List <ProductDTO>();

            for (int i = 0; i < Products_list.Count; i++)
            {
                list.Add(ProductBO.getProduct(Products_list[i]));
            }
            return(View(list));
        }
示例#31
0
        //
        // GET: /Product/

        public ActionResult Index(int?p)
        {
            ProductBO cls   = new ProductBO();
            var       model = cls.GetData();

            _session.IsLogin = false;
            int pageSize   = 9;
            int pageNumber = (p ?? 1);

            return(View(model.ToPagedList(pageNumber, pageSize)));
        }
示例#32
0
        public HttpResponseMessage insertProduct(ProductBO product)
        {
            int produ   = iproducts.AddProduct(product);
            var session = HttpContext.Current.Session;

            if (session != null)
            {
                HttpContext.Current.Session["ProductID"] = produ;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, "saved successfully"));
        }
示例#33
0
 public JsonResult GetProduct()
 {
     if (_session.IsLogin)
     {
         string jsonData = "[]";
         ProductBO _cls = new ProductBO();
         var data = _cls.GetList(m => m.IsActive.Equals(true));
         if (data != null)
             jsonData = new JavaScriptSerializer().Serialize(data);
         return Json(jsonData, JsonRequestBehavior.AllowGet);
     }
     else
         RedirectToAction("index", "admin");
     return Json("[]", JsonRequestBehavior.AllowGet);
 }
示例#34
0
 public JsonResult SaveProduct(Product product)
 {
     ProductBO cls = new ProductBO();
     bool IsResult = cls.Save(product);
     return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet);
 }
示例#35
0
 public ActionResult CreateProduct(int id)
 {
     ViewBag.ID = id;
     if (_session.IsLogin)
     {
         Product model = new Product();
         if (id != -1)
         {
             ProductBO cls = new ProductBO();
             model = cls.GetByID(id);
             if (model == null)
                 model = new Product();
             ViewBag.Image = model.ImageThumbnail;
             ViewBag.ImageLarge = model.ImageLarge;
             return View(model);
         }
         else
             return View(model);
     }
     else
         return RedirectToAction("index", "admin");
 }