コード例 #1
0
        public ActionResult Authorized(Users user)
        {
            if (!ModelState.IsValid)

            {
                return(View());
            }
            using (JobRegistryDBContext db = new JobRegistryDBContext())

            {
                Users u = db.Users.FirstOrDefault(model => model.UserName == user.UserName);

                if (u != null)
                {
                    ModelState.AddModelError("", "This username already exists.");
                    return(View());
                }

                db.Users.Add(user);
                db.SaveChanges();
            };
            return(RedirectToAction("Login"));

            //Get User login
        }
コード例 #2
0
 // GET: JobSeeker/Details/5
 public ActionResult Details(int id)
 {
     using (JobRegistryDBContext dbmodel = new JobRegistryDBContext())
     {
         return(View(dbmodel.JobSeekers.Where(x => x.ID == id).FirstOrDefault()));
     }
 }
コード例 #3
0
 public ActionResult Login(Users user)
 {
     using (JobRegistryDBContext db = new JobRegistryDBContext())
     {
         var usr = db.Users.Single(u => u.UserName == user.UserName && u.Password == user.Password);
         if (usr != null)
         {
             Session["UserID"]   = usr.ID.ToString();
             Session["Username"] = usr.UserName.ToString();
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Username or Password is wrong.");
         }
     }
     return(View());
 }
コード例 #4
0
        public ActionResult Create(JobSeeker jobSeeker)
        {
            try
            {
                // Create Jobseeker Details

                using (JobRegistryDBContext dbmodel = new JobRegistryDBContext())
                {
                    dbmodel.JobSeekers.Add(jobSeeker);
                    dbmodel.SaveChanges();
                }

                return(RedirectToAction("JobRegistration"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
        public ActionResult AddJobs(JobDetail JobId)
        {
            try
            {
                // Create Jobseeker Details

                using (JobRegistryDBContext dbmodel = new JobRegistryDBContext())
                {
                    dbmodel.JobDetails.Add(JobId);
                    dbmodel.SaveChanges();
                }

                return(RedirectToAction("AddJobs"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #6
0
 // GET: JobSeeker
 public ActionResult JobRegistration()
 {
     using (JobRegistryDBContext dbmodel = new JobRegistryDBContext())
         return(View(dbmodel.JobSeekers.ToList()));
 }
コード例 #7
0
 // GET: Jobs
 public ActionResult Joblist()
 {
     using (JobRegistryDBContext dbmodel = new JobRegistryDBContext())
         return(View(dbmodel.JobDetails.ToList()));
 }