public ActionResult Edit(int id) { EditScoreComment editScoreComment; editScoreComment = ScoreComments.GetByID(id); return(View(model: editScoreComment)); }
public ActionResult Edit(int id) { ScoreComment comment; var cmt = ScoreComments.GetByID(id); comment = Mapper.Map <ScoreComment>(cmt); return(View(url + "Edit.cshtml", comment)); }
public async Task <JsonResult> Get(int pageIndex, int pageSize, string pageOrder, int?productID, byte?scoreCommentStatus) { ScoreCommentStatus?status = null; if (scoreCommentStatus.HasValue) { status = (ScoreCommentStatus)scoreCommentStatus.Value; } if (pageOrder.Trim() == "ID") { pageOrder = "LastUpdate desc"; } var list = ScoreComments.Get(pageIndex, pageSize, pageOrder, productID, status); foreach (var item in list) { item.UserFullName = (await UserManager.FindByIdAsync(item.UserID)).Firstname + " " + (await UserManager.FindByIdAsync(item.UserID)).Lastname; } int total = ScoreComments.Count(productID, status); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
public ActionResult LatestComments(int id) { var cache = GetCache("Comments_" + id); var latestDate = ScoreComments.LatestLastUpdate(id); if (!cache.LastUpdate.HasValue || cache.LastUpdate.Value < latestDate) { cache.LastUpdate = latestDate; cache.Data = refreshComments(id); } return(Content(cache.Data.ToString(), "text/xml")); }
public ActionResult Edit(ScoreComment comment) { try { comment.LastUpdate = DateTime.Now; ViewBag.Success = true; ScoreComments.UpdateByUser(comment); } catch (Exception ex) { SetErrors(ex); } return(View(url + "Edit.cshtml", comment)); }
private static StringBuilder refreshComments(int productID) { var latestComments = new StringBuilder(); var productTitle = Products.GetTitleByID(productID); var comments = ScoreComments.GetLatestComments(productID); latestComments.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); latestComments.Append("<rss version=\"2.0\">"); latestComments.Append("<channel xmlns:atom=\"http://www.w3.org/2005/Atom\">"); latestComments.Append("<title>آخرین نظرات محصول " + productTitle + "</title>"); latestComments.Append("<link>" + StaticValues.WebsiteUrl + "</link>"); latestComments.Append("<description>" + StaticValues.WebsiteDescription + "</description>"); latestComments.Append("<language>fa-IR</language>"); latestComments.Append("<copyright>Copyright " + DateTime.Now.Year + " " + StaticValues.WebsiteTitle + ". All rights reserved.</copyright>"); latestComments.Append("<lastBuildDate>"); latestComments.Append(comments.Count > 0 ? RSSDateFormat(comments.First().LastUpdate) : ""); latestComments.Append("</lastBuildDate>"); foreach (var item in comments) { var product = Products.GetByID(item.ProductID); var group = Groups.GetByID(product.GroupID.Value); string url = (StaticValues.WebsiteUrl + UrlProvider.GetProductUrl(item.ProductID, group.UrlPerfix, product.UrlPerfix)).HtmlEncode(); latestComments.Append("<item>"); latestComments.Append("<guid isPermaLink=\"true\">" + url + "</guid>"); latestComments.Append("<link>" + url + "</link>"); latestComments.Append("<category>" + group.Title.HtmlEncode() + "</category>"); latestComments.AppendFormat("<title> نظر شماره {0} در {1}</title>", item.ID, (product.Title_En + " - " + product.Title).HtmlEncode()); latestComments.Append("<description>"); latestComments.Append(item.Text.HtmlEncode()); latestComments.Append("</description>"); latestComments.Append("<pubDate>" + RSSDateFormat(item.LastUpdate) + "</pubDate>"); latestComments.Append("</item>"); } latestComments.Append("</channel>"); latestComments.Append("</rss>"); return(latestComments); }
public ActionResult Edit(EditScoreComment editScoreComment) { try { var scoreComment = Mapper.Map <ScoreComment>(editScoreComment); scoreComment.LastUpdate = DateTime.Now; ViewBag.Success = true; ScoreComments.Update(scoreComment); } catch (Exception ex) { SetErrors(ex); } return(RedirectToAction("Index", "ScoreComments", new { ProductID = Request.QueryString["ProductID"] })); }
public JsonResult Delete(int id) { var jsonSuccessResult = new JsonSuccessResult(); try { ScoreComments.Delete(id); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public JsonResult Confirm(List <int> ids) { var jsonSuccessResult = new JsonSuccessResult(); try { ScoreComments.Confirm(ids); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public ActionResult Index() { var user = OSUsers.GetByID(UserID); var buyer = Mapper.Map <ViewBuyerInfo>(user); // TODO: UserAddresses buyer.StateName = user.StateID.HasValue ? Cities.GetCityName(user.StateID.Value) : String.Empty; buyer.CityName = user.CityID.HasValue ? Cities.GetCityName(user.CityID.Value) : String.Empty; MyAccountSettings model = new MyAccountSettings(); model.Orders = Carts.CountOrdersByUserID(UserID); model.OrdersSubmitted = Carts.CountOrdersByUserID(UserID, SendStatus.Sent); model.OrdersDelivered = Carts.CountOrdersByUserID(UserID, SendStatus.Delivered); model.Comments = ScoreComments.CountByUserID(UserID); model.CommentRates = ProductCommentRates.CountByUserID(UserID); model.Wishes = UserWishes.CountByUserID(UserID); model.Posts = Articles.CountByUserID(ArticleType.Blog, UserID); model.UserInfo = buyer; return(View("/Areas/User/Views/MyAccount/Index.cshtml", model: model)); }
public ActionResult Index() { var comments = ScoreComments.GetUserComments(UserID); return(View(url + "Index.cshtml", model: comments)); }