public ActionResult AddFavProduct(List <int> ProId) { var svFavProduct = new FavProductService(); b2bFavProduct model = new b2bFavProduct(); try { #region Set FavProduct Model foreach (var Pro in ProId) { var IsResult = svFavProduct.InsertFavProduct(Pro, LogonCompID); if (ProId.Count() == 1) { return(Json(IsResult)); } } #endregion } catch (Exception ex) { CreateLogFiles(ex); } return(Json(new { IsResult = svFavProduct.IsResult, MsgError = GenerateMsgError(svFavProduct.MsgError), ID = model.FavProductID })); }
public ActionResult addfav(int compid, int productid) { var svFav = new FavProductService(); var fav = new b2bFavProduct(); svFav.InsertFavProduct(productid, compid); return(Json(new { status = svFav.IsResult }, JsonRequestBehavior.AllowGet)); }
public FavoriteController() { svFavProduct = new FavProductService(); svFavBuylead = new FavBuyleadService(); svFavCompany = new FavCompanyService(); svBizType = new BizTypeService(); svCompany = new CompanyService(); svAddress = new AddressService(); }
public ActionResult GetProductName(string query) { svFavProduct = new FavProductService(); sqlWhere = svFavProduct.CreateWhereAction(FavAction.IsFav, 0); sqlWhere += svFavProduct.CreateWhereCause(0, query, 0, 0, 0, 0, 0, 0, 0); var FavProducts = svFavProduct.SelectData <view_FavProduct>("ProductName", sqlWhere, "ProductName"); var ProductName = FavProducts.Select(it => it.ProductName).ToList(); return(Json(ProductName)); }
public ActionResult delfav(int productid, int compid) { var svFav = new FavProductService(); var fav = new b2bFavProduct(); var lstProductID = new List <int>(); if (productid > 0) { lstProductID.Add(productid); svFav.Delete(lstProductID, compid); } return(Json(new { status = svFav.IsResult }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteFavProduct(List <int> ProductID) { var svFavProduct = new FavProductService(); try { svFavProduct.Delete(ProductID, LogonCompID); } catch (Exception ex) { svFavProduct.MsgError.Add(ex); CreateLogFiles(ex); } return(Json(new { IsResult = svFavProduct.IsResult, MsgError = GenerateMsgError(svFavProduct.MsgError) })); }
// #region myfav list public ActionResult myfav(int compid, int pageindex = 1, int pagesize = 50) { var svFav = new FavProductService(); var svProduct = new ProductService(); var fav = svFav.SelectData <view_FavProduct>(" * ", "isdelete = 0 AND compid = " + compid, "", pageindex, pagesize); var product = new List <ProductModel>(); var gallery = new List <b2bProductImage>(); var whereGallery = "IsDelete = 0"; #region product gallery if (svFav.TotalRow > 0) { List <int> productid = fav.Select(m => (int)m.ProductID).ToList(); whereGallery += " AND " + CreateWhereIN(productid, "productid"); var data = svProduct.SelectData <b2bProductImage>(" * ", whereGallery); foreach (var p in fav) { var item = new ProductModel(); #region set product model item.productid = (int)p.ProductID; item.productname = p.ProductName; item.price = (decimal)p.Price; //item.promotionprice = (p.PromotionPrice > 0) ? (decimal)p.PromotionPrice : 0; //item.ispromotion = (p.IsPromotion != null) ? (bool)p.IsPromotion : false; item.compname = p.CompName; item.compid = (int)p.ProductCompID; item.complevel = (int)p.CompLevel; item.createdate = p.CreatedDate; item.modifieddate = p.ModifiedDate; item.imagepath = p.ProductImgPath; item.productdetail = p.ProductDetail; item.shortdescription = (!string.IsNullOrEmpty(p.ShortDescription))?p.ShortDescription.Replace("~", " "):""; item.isfav = true; item.gallery = new List <GalleryModel>(); #endregion #region First Image var g = new GalleryModel(); g.imageid = 0; g.imagepath = p.ProductImgPath; item.gallery.Add(g); #endregion if (data != null && data.Count > 0) { foreach (var it in data.Where(m => m.ProductID == p.ProductID)) { g = new GalleryModel(); g.imageid = it.ProductImageID; g.imagepath = it.ImgPath; item.gallery.Add(g); } } product.Add(item); } } #endregion return(Json(new { favorites = product, totalrow = svFav.TotalRow, totalpage = svFav.TotalPage }, JsonRequestBehavior.AllowGet)); }