public ActionResult AjaxAddFav(FormCollection Fm) { if (string.IsNullOrWhiteSpace(Fm["ProductId"])) { return base.Content("False"); } int num = Globals.SafeInt(Fm["ProductId"], 0); Maticsoft.BLL.Shop.Favorite favorite = new Maticsoft.BLL.Shop.Favorite(); if (favorite.Exists((long) num, base.currentUser.UserID, 1)) { return base.Content("Rep"); } Maticsoft.Model.Shop.Favorite model = new Maticsoft.Model.Shop.Favorite { CreatedDate = DateTime.Now, TargetId = num, Type = 1, UserId = base.currentUser.UserID }; if (favorite.Add(model) <= 1) { return base.Content("False"); } return base.Content("True"); }
public ActionResult RemoveFavorItem(FormCollection Fm) { if (!string.IsNullOrWhiteSpace(Fm["ItemId"])) { string text = Fm["ItemId"]; Maticsoft.BLL.Shop.Favorite favorite = new Maticsoft.BLL.Shop.Favorite(); int favoriteId = Globals.SafeInt(text, 0); if (favorite.Delete(favoriteId)) { return base.Content("Ok"); } } return base.Content("No"); }
public PartialViewResult FavorList(int pageIndex = 1, string viewName = "_FavorList") { Maticsoft.BLL.Shop.Favorite favorite = new Maticsoft.BLL.Shop.Favorite(); StringBuilder builder = new StringBuilder(); builder.AppendFormat(" favo.UserId ={0} and favo.Type= {1} ", base.CurrentUser.UserID, 1); int pageSize = 4; int startIndex = (pageIndex > 1) ? (((pageIndex - 1) * pageSize) + 1) : 0; int endIndex = pageIndex * pageSize; int recordCount = favorite.GetRecordCount(string.Concat(new object[] { " UserId =", base.CurrentUser.UserID, " and Type=", 1 })); if (recordCount < 1) { return base.PartialView(viewName); } PagedList<FavoProdModel> model = new PagedList<FavoProdModel>(favorite.GetFavoriteProductListByPage(builder.ToString(), startIndex, endIndex), pageIndex, pageSize, recordCount); if (base.Request.IsAjaxRequest()) { return this.PartialView(viewName, model); } return this.PartialView(viewName, model); }