Example #1
0
        public ActionResult Writer(Nahid usr, string rdMale, string rdFemale)
        {
            if (!string.IsNullOrEmpty(rdMale))
            {
                usr.Gender = true;
            }
            if (!string.IsNullOrEmpty(rdFemale))
            {
                usr.Gender = false;
            }
            usr.DateofBrith = DateTime.Now;
            usr.Author      = true;
            usr.Online      = true;
            usr.Approved    = true;
            context.Nahids.Add(usr);
            context.SaveChanges();
            Role     author = context.Roles.FirstOrDefault(x => x.RoleName == "Author");
            UserRole usrl   = new UserRole();

            usrl.UserRoleId = author.RoleId;
            usrl.UserID     = usr.UserId;
            context.UserRoles.Add(usrl);
            context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
        public ActionResult Approved(int id)
        {
            Nahid usr = context.Nahids.FirstOrDefault(x => x.UserId == id);

            usr.Approved = true;
            context.SaveChanges();
            return(RedirectToAction("AuthorApprovals"));
        }
Example #3
0
        string ValidateUser(string nn, string pwd)
        {
            Nahid usr = context.Nahids.FirstOrDefault(x => x.UserName == nn && x.Password == pwd);

            if (usr != null)
            {
                return(usr.UserName);
            }
            else
            {
                return("");
            }
        }
Example #4
0
 public ActionResult LogIn(Nahid usr, string rdMale, string rdFemale)
 {
     if (!string.IsNullOrEmpty(rdMale))
     {
         usr.Gender = true;
     }
     if (!string.IsNullOrEmpty(rdFemale))
     {
         usr.Gender = false;
     }
     usr.Author           = true;
     usr.Approved         = false;
     usr.Online           = true;
     usr.RegistrationDate = DateTime.Now;
     context.Nahids.Add(usr);
     context.SaveChanges();
     return(RedirectToAction("SignIn"));
 }
Example #5
0
        public ActionResult SignIn(Nahid usr)
        {
            string ka = ValidateUser(usr.UserName, usr.Password);

            if (!string.IsNullOrEmpty(ka))
            {
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usr.UserName, DateTime.Now, DateTime.Now.AddMinutes(15), true, ka, FormsAuthentication.FormsCookiePath);
                HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName);
                if (ticket.IsPersistent)
                {
                    ck.Expires = ticket.Expiration;
                }

                Response.Cookies.Add(ck);

                FormsAuthentication.RedirectFromLoginPage(usr.UserName, true);
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #6
0
 public ActionResult DaxilOl(Nahid nhd)
 {
     context.Nahids.Add(nhd);
     context.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }