Beispiel #1
0
 // GET: Account
 public ActionResult Login()
 {
     if (HttpContext.User.Identity.IsAuthenticated)
     {
         AppUser appUser = _appUserRepo.FindByUserName(HttpContext.User.Identity.Name);
         if (appUser.Status != Status.Passive)
         {
             if (appUser.Role == Role.Admin)
             {
                 string cookie = appUser.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["FullName"]  = appUser.FirstName + " " + appUser.LastName;
                 Session["ImagePath"] = appUser.UserImage;
                 return(Redirect("/Admin/Home/Index"));
             }
             else if (appUser.Role == Role.Author)
             {
                 string cookie = appUser.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["FullName"]  = appUser.FirstName + " " + appUser.LastName;
                 Session["ImagePath"] = appUser.UserImage;
                 return(Redirect("/Author/Home/Index"));
             }
             else
             {
                 string cookie = appUser.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["FullName"]  = appUser.FirstName + " " + appUser.LastName;
                 Session["ImagePath"] = appUser.UserImage;
                 return(Redirect("/Member/Home/Index"));
             }
         }
         else
         {
             ViewData["error"] = "Please register out web side..!";
             return(View());
         }
     }
     else
     {
         TempData["class"] = "custom-hide";
         return(View());
     }
 }
Beispiel #2
0
        public JsonResult AddComment(string userComment, int id)
        {
            Comment comment = new Comment();

            comment.AppUserId     = _appUserRepo.FindByUserName(HttpContext.User.Identity.Name).Id;
            comment.NewsArticleId = id;
            comment.Text          = userComment;

            bool isAdded = false;

            try
            {
                _commentRepo.Add(comment);
                isAdded = true;
            }
            catch (Exception)
            {
                isAdded = false;
            }

            return(Json(isAdded));
        }