public IActionResult SaveMessage(TblFeedback model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var cinemaAdded = _context.TblFeedback.Add(model);

            if (_context.SaveChanges() == 0)
            {
                return(View("Contact").WithDanger("Info!", "Your comment could not be saved!"));
            }

            return(View("Index").WithSuccess("Info!", "Your comment was saved successfully!"));
        }
Пример #2
0
 public ActionResult DeleteFeedback(int id)
 {
     if (ClsCheckRole.CheckQuyen(8, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
     {
         TblFeedback feedback = db.TblFeedback.Find(id);
         var         result   = string.Empty;
         db.TblFeedback.Remove(feedback);
         db.SaveChanges();
         result = "Bạn đã xóa thành công.";
         return(Json(new { result = result }));
     }
     else
     {
         var result = string.Empty;
         result = "Bạn không có quyền thay đổi tính năng này";
         return(Json(new { result = result }));
     }
 }
Пример #3
0
        public ActionResult Index(int?page, string id, FormCollection collection)
        {
            if ((Request.Cookies["Username"] == null))
            {
                return(RedirectToAction("LoginIndex", "Login"));
            }
            if (ClsCheckRole.CheckQuyen(8, 0, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
            {
                var listFeedback = db.TblFeedback.ToList();

                const int pageSize   = 20;
                var       pageNumber = (page ?? 1);
                // Thiết lập phân trang
                var ship = new PagedListRenderOptions
                {
                    DisplayLinkToFirstPage                      = PagedListDisplayMode.Always,
                    DisplayLinkToLastPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToPreviousPage                   = PagedListDisplayMode.Always,
                    DisplayLinkToNextPage                       = PagedListDisplayMode.Always,
                    DisplayLinkToIndividualPages                = true,
                    DisplayPageCountAndCurrentLocation          = false,
                    MaximumPageNumbersToDisplay                 = 5,
                    DisplayEllipsesWhenNotShowingAllPageNumbers = true,
                    EllipsesFormat                     = "…",
                    LinkToFirstPageFormat              = "Trang đầu",
                    LinkToPreviousPageFormat           = "«",
                    LinkToIndividualPageFormat         = "{0}",
                    LinkToNextPageFormat               = "»",
                    LinkToLastPageFormat               = "Trang cuối",
                    PageCountAndCurrentLocationFormat  = "Page {0} of {1}.",
                    ItemSliceAndTotalFormat            = "Showing items {0} through {1} of {2}.",
                    FunctionToDisplayEachPageNumber    = null,
                    ClassToApplyToFirstListItemInPager = null,
                    ClassToApplyToLastListItemInPager  = null,
                    ContainerDivClasses                = new[] { "pagination-container" },
                    UlElementClasses                   = new[] { "pagination" },
                    LiElementClasses                   = Enumerable.Empty <string>()
                };
                ViewBag.ship = ship;
                if (Session["Thongbao"] != null && Session["Thongbao"] != "")
                {
                    ViewBag.thongbao    = Session["Thongbao"].ToString();
                    Session["Thongbao"] = "";
                }
                if (collection["btnDelete"] != null)
                {
                    foreach (string key in Request.Form.Keys)
                    {
                        var checkbox = "";
                        if (key.StartsWith("chk_"))
                        {
                            checkbox = Request.Form["" + key];
                            if (checkbox != "false")
                            {
                                if (ClsCheckRole.CheckQuyen(8, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true)
                                {
                                    int         ids      = Convert.ToInt32(key.Remove(0, 4));
                                    TblFeedback feedback = db.TblFeedback.Find(ids);
                                    db.TblFeedback.Remove(feedback);
                                    db.SaveChanges();
                                    return(RedirectToAction("Index"));
                                }
                                else
                                {
                                    return(Redirect("/Users/Erro"));
                                }
                            }
                        }
                    }
                }
                return(View(listFeedback.ToPagedList(pageNumber, pageSize)));
            }
            else
            {
                return(Redirect("/Users/Erro"));
            }
        }