Exemplo n.º 1
0
        public ActionResult AppliedJob(int?id)                          // Apply for A job Application
        {
            AppliedUser tryingtoapplyuser = new AppliedUser();

            if (id == null)
            {
                return(HttpNotFound());
            }

            Session["jobId"] = id;                                           // to send it to post method !!!
            tryingtoapplyuser.AppliedUserId = User.Identity.GetUserId();
            tryingtoapplyuser.JobId         = (int)Session["jobId"];

            try
            {
                //check if the user applied before or not by its ID And the Job_ID
                if (db.AppliedUsers.Where
                        ((ch => ch.AppliedUserId == tryingtoapplyuser.AppliedUserId && ch.JobId == tryingtoapplyuser.JobId))
                    .FirstOrDefault().IsApplied == true)
                {
                    var infoofuser = db.AppliedUsers.Where(c => c.AppliedUserId == tryingtoapplyuser.AppliedUserId && c.JobId == tryingtoapplyuser.JobId).FirstOrDefault();

                    return(RedirectToAction("applied", "Candidate", new { dt = infoofuser.Applyon, masge = infoofuser.UserMessage })); //  applied before view;
                }
            }

            catch
            {
            }

            return(View());
        }
Exemplo n.º 2
0
        public ActionResult AppliedJob(AppliedUser appuser)             //user Apply for A job Application  [post]
        {
            if (ModelState.IsValid)
            {
                appuser.AppliedUserId = User.Identity.GetUserId();
                appuser.JobId         = (int)Session["jobId"];
                appuser.Applyon       = DateTime.Now;
                appuser.IsApplied     = true;
                db.AppliedUsers.Add(appuser);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            return(View(appuser));
        }
Exemplo n.º 3
0
        public ActionResult app_Edit(AppliedUser newappl)
        {
            var us = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                var application = db.AppliedUsers.Where(ap => ap.JobId == newappl.JobId && ap.AppliedUserId == us).SingleOrDefault();

                application.AppliedUserId = newappl.AppliedUserId;
                application.JobId         = newappl.JobId;
                application.IsApplied     = newappl.IsApplied;
                application.UserMessage   = newappl.UserMessage;
                application.Applyon       = DateTime.Now;


                db.SaveChanges();
                return(RedirectToAction("application"));
            }
            return(View(newappl));
        }