예제 #1
0
        // GET: Comment/Delete/5
        public ActionResult Delete(int id)
        {
            if (SessionManager.User is null)
            {
                return(RedirectToAction("Index", "Auth"));
            }

            G.Comment comment = _apiTokenRequester.GetWithToken <G.Comment>("comment/" + id, SessionManager.User.Token);
            ViewBag.returnUrl = Request.Headers["Referer"].ToString(); //stock l'url de la page qui appel la méthode delete, dans ce cas : Details/id

            return(View(comment));
        }
예제 #2
0
        public ActionResult Comment(G.Comment comment)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _apiRequester.Create(comment, "comment");
                    return(RedirectToAction(nameof(Details), new { id = comment.EventId }));
                }

                return(View(comment));
            }
            catch
            {
                return(View("Error"));
            }
        }
예제 #3
0
        public ActionResult Edit(int id, G.Comment comment)
        {
            try
            {
                if (!(SessionManager.User.Token is null) && comment.UserId == SessionManager.User.Id)
                {
                    if (_apiTokenRequester.UpdateWithToken(comment, "comment/" + id, SessionManager.User.Token))
                    {
                        return(RedirectToAction(nameof(Details), new { id = comment.EventId }));
                    }

                    ViewBag.Message = "Update failed";
                    return(View(comment));
                }

                ViewBag.Message = "Session has expired";
                return(RedirectToAction("Index", "Auth"));
            }

            catch
            {
                return(View("Error"));
            }
        }