public ActionResult JobDistro() { var db = new JobsDataContext(); var JobCount = new List<int>(); var Engineers = Engineer_List.Skip(1); foreach (string Engineer in Engineer_List.Skip(1)) { var jobsbyEng = db.Jobs.Where(job => job.Engineer == Engineer).Count(); JobCount.Add(jobsbyEng); } ViewBag.JobCounts = JobCount; ViewBag.Engineers = Engineers; ViewData["Engineers"] = Engineers.ToArray(); return View(); }
public ActionResult AddRevision(Models.Job job) { if (ModelState.IsValid) { var db = new JobsDataContext(); char current_Revision = char.Parse(job.curr_Revision); current_Revision++; job.curr_Revision = current_Revision.ToString(); #if DEBUG Debug.WriteLine("Current Revision: " + job.curr_Revision); #endif db.Jobs.Add(job); db.SaveChanges(); } return RedirectToAction("Index"); }
// Finds job based on passed in name (Job number) public ActionResult FindJob(string name) { var db = new JobsDataContext(); if (name != "") { var job = (IEnumerable<Models.Job>)db.Jobs.Where(t => t.name == name); if (job == null) { Index(); return View("Index"); } else { return View(job); } } else { var job = (IEnumerable<Models.Job>)db.Jobs; if (job == null) { Index(); return View("Index"); } else { return View(job); } } }
// Main entry point for the user public ActionResult Index() { var db = new JobsDataContext(); var jobs = db.Jobs.ToArray(); var model = jobs.Select(t => new SelectListItem { Text = t.name.ToString(), Value = t.name.ToString() }).ToList(); model.Insert(0, new SelectListItem { Value = "-1", Text = "Select a Job" }); ViewData["TableSelect"] = model; return View(); }
public ActionResult Edit(Models.Job editedjob) { if (ModelState.IsValid) { // Save to the database var db = new JobsDataContext(); db.Entry(editedjob).State = System.Data.EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } else { return Edit(editedjob.Id); } }
public ActionResult Edit(long id) { //ViewData["PMLIST"] = new SelectList(PM_List); //ViewData["ENGINEERLIST"] = new SelectList(Engineer_List); //ViewData["StatusList"] = new SelectList(Status_List); ViewBag.PMList = new SelectList(PM_List); ViewBag.StatusList = new SelectList(Status_List); ViewBag.EngineerList = new SelectList(Engineer_List); ViewBag.DeviceList = new SelectList(DeviceTypes); ViewBag.ReportList = new SelectList(ReportTypes); ViewBag.CaliperList = new SelectList(Caliper_List); ViewBag.MicrometerList = new SelectList(Micrometer_List); ViewBag.ScaleList = new SelectList(Scale_List); ViewBag.TWList = new SelectList(TW_List); ViewBag.ProtractorList = new SelectList(Protractor_List); ViewBag.LVForceList = new SelectList(LVF_List); ViewBag.LVTorqueList = new SelectList(LVT_List); var db_Customer = new CustomersDataContext(); var customers = (IEnumerable<Models.Customer>)db_Customer.Customers; List<string> customer_List = new List<string>(); List<string> customer_Companies = new List<string>(); customer_List.Add(""); customer_Companies.Add(""); foreach (Customer customer in customers) { customer_List.Add(customer.first_Name + " " + customer.last_Name); customer_Companies.Add(customer.Company_Name.ToString()); } ViewBag.CustomerList = new SelectList(customer_List); ViewBag.CompanyList = new SelectList(customer_Companies); var db = new JobsDataContext(); var job = db.Jobs.Find(id); return View(job); }
// Grabs data and returns view for the due date summary public ActionResult DueDate() { var db = new JobsDataContext(); var done_jobs = (IEnumerable<Job>)db.Jobs.Where(job => job.Status == "Done").OrderByDescending(job => job.Engineer); return View(done_jobs); }
// Need to create a view for this...currently the only prompt is given by jQuery. public ActionResult Delete(Models.Job job) { var db = new JobsDataContext(); db.Entry(job).State = System.Data.EntityState.Deleted; db.SaveChanges(); return View("Index"); }
public ActionResult Create(Models.Job newjob) { if (ModelState.IsValid) { // Save to the database var db = new JobsDataContext(); // Sets the current revision to A, as it should be for any new job created newjob.curr_Revision = "A"; db.Jobs.Add(newjob); // Checks to see if there are any validation errors returned by the JobsDataContext comparitor if (db.GetValidationErrors().Count() > 0) { return RedirectToAction("Create"); } else { db.SaveChanges(); } return RedirectToAction("Index"); } return Create(); }