Example #1
0
 public IActionResult Claim(Job job)
 {
     job.Worker          = db.Workers.FirstOrDefault(worker => worker.UserName == User.Identity.Name); // In the database, the worker who is signed in is assigned this job.
     db.Entry(job).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #2
0
 public IActionResult Claim(Job job)
 {
     job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
     db.Entry(job).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #3
0
 public IActionResult Claim(Job job)
 // This route claims a job for a worker, and makes the appropriate edits in the database. There is currently no funcitonality to un-claim a job
 {
     job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
     db.Entry(job).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public IActionResult MarkActive(Job job)
 {
     job.Pending         = true;
     job.Completed       = false;
     db.Entry(job).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #5
0
        //setting a worker to status unavail
        public IActionResult changeToUnavail(int id)
        {
            Worker thisWorker = db.Workers.FirstOrDefault(w => w.WorkerId == id);

            thisWorker.Avaliable       = false;
            db.Entry(thisWorker).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IActionResult Claim(int id, string title)
        {
            Job thisJob = db.Jobs.FirstOrDefault(j => j.JobId == id);

            thisJob.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            db.Entry(thisJob).State = EntityState.Modified;
            db.SaveChanges();
            return(Content(""));
        }
Example #7
0
        public IActionResult Claim(int JobId)
        {
            Job job = db.Jobs.FirstOrDefault(j => j.JobId == JobId);

            job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(job));
        }
        public IActionResult ClaimConfirmed(int id)
        {
            var thisJob = db.Jobs.FirstOrDefault(jobs => jobs.JobId == id);

            thisJob.Worker          = db.Workers.FirstOrDefault(workers => workers.UserName == User.Identity.Name);
            db.Entry(thisJob).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(thisJob));
        }
        public IActionResult SubmitClaim(int JobId)
        {
            //action starts the process of editing the job status, but needs to actually change pending boolean to true based on AJAX
            Job thisJob = db.Jobs.FirstOrDefault(jobs => jobs.JobId == JobId);

            thisJob.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            thisJob.Pending         = true;
            db.Entry(thisJob).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #10
0
        public IActionResult Claim(int jobId, string userName)
        {
            //job.Worker = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            //Since Ajax is used, the parameters should be changed to int and string
            var thisJob = db.Jobs.FirstOrDefault(jobs => jobs.JobId == jobId);

            thisJob.Worker          = db.Workers.FirstOrDefault(i => i.UserName == userName);
            db.Entry(thisJob).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(thisJob.Worker));
        }
Example #11
0
        public IActionResult ClaimJobCtrl(int id)
        {
            Job    thisJobId = db.Jobs.FirstOrDefault(m => m.JobId == id);
            Worker worker    = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);

            thisJobId.Worker          = worker;
            db.Entry(worker).State    = EntityState.Modified;
            db.Entry(thisJobId).State = EntityState.Modified;
            db.SaveChanges();
            var nameWroker = worker.FirstName + worker.LastName;

            return(Json(nameWroker));
        }
        public IActionResult Active(int theId)
        {
            var thisJob = db.Jobs.FirstOrDefault(job => job.JobId == theId);

            foreach (var job in db.Jobs)
            {
                job.Pending         = false;
                db.Entry(job).State = EntityState.Modified;
            }
            thisJob.Pending         = true;
            db.Entry(thisJob).State = EntityState.Modified;
            db.SaveChanges();

            return(Content(theId.ToString(), "text/plain"));
        }
        public IActionResult Claim(int id)
        {
            Job job = db.Jobs.FirstOrDefault(items => items.JobId == id);

            job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Content(id.ToString(), "text/plain"));
        }
Example #14
0
        public IActionResult MarkAsCompleated(int jobid)
        {
            var job = db.Jobs.FirstOrDefault(j => j.JobId == jobid);

            job.Completed       = true;
            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Content(" ", "text/plain"));
        }
Example #15
0
        //when in index (job/index) and click "caim this job" button you are direted to a "confirmation" (jobs/claim) page where you actually have the abuility to link a worker to a job in the database

        //public IActionResult Claim(int id)
        //{
        //    var thisItem = db.Jobs.FirstOrDefault(items => items.JobId == id);
        //    return View(thisItem);
        //}

        //when on the "confirmation" (jobs/claim) page you can click "Claim This Job" and that will redirect you to the index after updating the WorkerId in the Jobs-table with the id of the user(worker) who clicked the button


        //[HttpPost]
        public IActionResult Claim(int jobId, string userName)
        {
            var job = db.Jobs.FirstOrDefault(i => i.JobId == jobId);

            job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == userName);
            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Content("Job caimed", "text/plain"));
        }
Example #16
0
        public IActionResult Claim(int jobId)
        {
            Debug.WriteLine("jobjobId :" + jobId);
            Job job = db.Jobs.FirstOrDefault(j => j.JobId == jobId);

            Debug.WriteLine("job Description " + job.Description);
            job.Worker          = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);
            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(job));
        }
Example #17
0
        public IActionResult ClaimJob(int jobId)
        {
            Job    job            = db.Jobs.Include(items => items.Worker).FirstOrDefault(items => items.JobId == jobId);
            Worker claimingWorker = db.Workers.FirstOrDefault(i => i.UserName == User.Identity.Name);

            if (claimingWorker.Available)
            {
                claimingWorker.Available = false;
                job.Worker = claimingWorker;
            }

            db.Entry(job).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(job));
        }
Example #18
0
 public IActionResult Edit(Worker worker)
 {
     db.Entry(worker).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }