public ActionResult Edit(ps_ProductCreate model) { if (ModelState.IsValid) { bn_Product bnProduct = new bn_Product(); bn_ProductTag bnProductTag = new bn_ProductTag(model.Product.ProductId); bnProduct.Update( model.Product.ProductId, model.Product.Name, model.Product.Price, model.Product.Description); //photos List <ps_ProductPhoto> photos = (List <ps_ProductPhoto>)Session["Photos"]; Photo_UpdateProductId( model.Product.ProductId, photos); //update hashtags //is under construction bnProductTag.RemoveAll(); bnProductTag.TagedToSome(model.Tags, model.Product.UserId); return(RedirectToAction("Detail", new { productId = model.Product.ProductId })); } model.Product.Description = HttpUtility.HtmlDecode(model.Product.Description); return(View(model)); }
public ActionResult Edit(Guid productId) { bn_Product bnProduct = new bn_Product(); pb_Product product = bnProduct.GetById(productId); if (product != null) { bn_Photo bnPhoto = new bn_Photo(); bn_ProductTag bnProductTag = new bn_ProductTag(productId); ps_ProductCreate model = new ps_ProductCreate(); var photoList = bnPhoto.GetByProductId(productId); List <ps_ProductPhoto> photos = new List <ps_ProductPhoto>(); foreach (var item in photoList) { photos.Add(new ps_ProductPhoto { PhotoId = item.PhotoId, PhotoPath = item.ImagePath }); } model.Product = product; model.Product.Description = HttpUtility.HtmlDecode(model.Product.Description); model.Tags = bnProductTag.GetTagedList(); model.ProductPhotos = photos; Session["Photos"] = new List <ps_ProductPhoto>(); return(View(model)); } else { //redirect to error page return(RedirectToAction("Error404", "Error")); } }
// // GET: /Product/ public ActionResult Index() { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByTags("pbox"); var model1 = bnProduct.GetAll(); return(View(model)); }
public ActionResult Category(string tag, string category) { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByCategory(tag, category); ViewBag.TagName = tag; return(View("Index", model)); }
public ActionResult Own() { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByUserId( ps_Membership.GetUser().UserId); return(View(model)); }
public ActionResult Delete(Guid id) { bn_Product bnProduct = new bn_Product(); bnProduct.UpdateStatus( id, EProduct_Status.UnAvailable); return(Redirect("/")); }
//[Authorize] public ActionResult Detail(Guid productId) { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetById(productId); bnProduct.IncrViews(model.ProductId); return(View(model)); }
public ActionResult Favourite() { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByUserAndTagName( ps_Membership.GetUser().UserId, ESpecialTag.Favourite.ParseToText()); return(View(model)); }
public ActionResult WishList() { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByUserAndTagName( ps_Membership.GetUser().UserId, ESpecialTag.Favourite.ParseToText()); ViewBag.TagName = "wish list"; return(View("Index", model)); }
public ActionResult Filter(string request) { bn_Product bnProduct = new bn_Product(); var model = bnProduct.GetByTags(request); var tags = bn_HashTag.DivTags(request); ViewBag.Tags = tags; ViewBag.FilterRequest = bn_HashTag.MergerTag(tags); return(View(model)); }
public ActionResult Index(Guid?tagId, string tagName = "pbox") { bn_Product bnProduct = new bn_Product(); List <pb_Product> model = new List <pb_Product>(); if (!tagId.HasValue) { model = bnProduct.GetByTagName(tagName); } else { model = bnProduct.GetByHashTagId(tagId.Value); } ViewBag.TagName = tagName; return(View(model)); }
public ActionResult Add(ps_ProductCreate model) { List <ps_ProductPhoto> photos = (List <ps_ProductPhoto>)Session["Photos"]; if (ModelState.IsValid && photos.Count > 0) { var bnProduct = new bn_Product(); var productId = bnProduct.Create( ps_Membership.GetUser().UserId, model.Product.Name, model.Product.Price, model.Product.Description); if (productId != null) { var bnProductTag = new bn_ProductTag(productId); //updated photos for product Photo_UpdateProductId(productId, photos); //tag product to some hash var tagList = bn_HashTag.DivTags(model.Tags); foreach (var tag in tagList) { bnProductTag.Tag( tag, ps_Membership.GetUser().UserId, null); } return(RedirectToAction("Detail", new { productId = productId })); } //alert error return(View(model)); } Session["Photos"] = photos; model.ProductPhotos = new List <ps_ProductPhoto>(); return(View(model)); }
public ActionResult New(Guid productId) { bn_Product bnProduct = new bn_Product(); ps_Order model = new ps_Order(); var user = ps_Membership.GetUser(); var product = bnProduct.GetById(productId); if (user != null) { //add some default values. model.Order.UserId = user.UserId; model.Order.CustomerName = user.FullName; } model.Order.Price = (product.DiscountPrice.HasValue) ? product.DiscountPrice.Value : product.Price; model.Order.Amount = 1; model.Order.ProductId = productId; model.Product = product; return(View(model)); }
public List <pb_Product> Filter(string tag) { bn_Product bnProduct = new bn_Product(isLazy: false); return(bnProduct.GetByTagName(tag)); }
public List <pb_Product> GetAll() { bn_Product bnProduct = new bn_Product(isLazy: false); return(bnProduct.GetAll()); }
public ActionResult List(Guid?tagId, string tagName = "juddy", int page = 0) { int itemsPerPage = 36; if (page < 0) { page = 0; } bn_Product bnProduct = new bn_Product(); List <pb_Product> model = new List <pb_Product>(); int tmpPages; if (!tagId.HasValue) { var tmpAll = bnProduct.GetByTagName(tagName).Count; tmpPages = tmpAll / itemsPerPage; if (tmpPages * itemsPerPage < tmpAll) { tmpPages++; } tmpPages--; if (page > tmpPages) { page = tmpPages; } model = bnProduct.GetByTagName(tagName) .Skip(page * itemsPerPage) .Take(itemsPerPage).ToList(); } else { var tmpAll = bnProduct.GetByHashTagId(tagId.Value).Count; tmpPages = tmpAll / itemsPerPage; if (tmpPages * itemsPerPage < tmpAll) { tmpPages++; } tmpPages--; if (page > tmpPages) { page = tmpPages; } bn_HashTag bnHashtag = new bn_HashTag(); tagName = bnHashtag.GetById(tagId.Value).TagName; model = bnProduct.GetByHashTagId(tagId.Value) .Skip(page * itemsPerPage) .Take(itemsPerPage).ToList(); } if (page > 0) { ViewBag.Back = "OK"; } else { ViewBag.Back = "Disable"; } if (page < tmpPages) { ViewBag.Next = "OK"; } else { ViewBag.Next = "Disable"; } ViewBag.CurrentPage = page; ViewBag.TagName = tagName; return(View("Index", model)); }