예제 #1
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoleId = new SelectList(db.Roles, "RoleId", "RoleName", user.RoleId);
     return(View(user));
 }
예제 #2
0
        public ActionResult Create(Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
        public ActionResult Create(JobCategory jobcategory)
        {
            if (ModelState.IsValid)
            {
                db.JobCategories.Add(jobcategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(jobcategory));
        }
예제 #4
0
        public ActionResult Create(JobDescription jobdescription)
        {
            if (ModelState.IsValid)
            {
                db.JobDescriptions.Add(jobdescription);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.JobCategoryId = new SelectList(db.JobCategories, "JobCategoryId", "CategoryName", jobdescription.JobCategoryId);
            ViewBag.UserId        = db.Users.First(u => u.UserName == User.Identity.Name).UserId;
            return(View(jobdescription));
        }
        public override MembershipUser CreateUser(string firstName, string lastName, string username, string password, string email,
                                                  bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var entities = new BdJobsEntities();

            if (entities.Users.Any(u => u.UserName == username))
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }
            else if (entities.Users.Any(u => u.Email == email))
            {
                status = MembershipCreateStatus.DuplicateEmail;
            }
            else
            {
                string hPassword = GetSHA1HashData(password);

                var user = new User {
                    UserName = username, Password = hPassword, RoleId = 3, FirstName = firstName, LastName = lastName, Email = email
                };
                entities.Users.Add(user);
                entities.SaveChanges();
                status = MembershipCreateStatus.Success;
            }

            return(null);
        }