public ActionResult Create([Bind(Include = "Id,SubcontractorId,TotBedNights,TotOverallServed,TotA2AEnrollment,TotA2ABedNights,SubmittedDate,MA2Apercent,ClientsJobEduServ,ParticipatingFathers,TotEduClasses,TotClientsinEduClasses,TotCaseHrs,TotClientsCaseHrs,TotOtherClasses,Year,Months")] NonResidentialMIR nonResidentialMIR) { if (ModelState.IsValid) { var dataexist = from s in db.NonResidentialMIRs where s.SubcontractorId == nonResidentialMIR.SubcontractorId && s.Year == nonResidentialMIR.Year && s.Months == nonResidentialMIR.Months select s; if (dataexist.Count() >= 1) { ViewBag.error = "Data already exists. Please change the params or search in the Reports tab for the current Record."; } else { nonResidentialMIR.SubmittedDate = DateTime.Now; nonResidentialMIR.Id = Guid.NewGuid(); db.NonResidentialMIRs.Add(nonResidentialMIR); db.SaveChanges(); return(RedirectToAction("Index", "ResidentialMIRs")); } } var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList(); ViewBag.Year = new SelectList(datelist); ViewBag.SubcontractorId = new SelectList(db.SubContractors, "SubcontractorId", "OrgName", nonResidentialMIR.SubcontractorId); return(View(nonResidentialMIR)); }
public ActionResult DeleteConfirmed(Guid id) { NonResidentialMIR nonResidentialMIR = db.NonResidentialMIRs .Include(s => s.Subcontractor) .SingleOrDefault(); db.NonResidentialMIRs.Remove(nonResidentialMIR); db.SaveChanges(); return(RedirectToAction("Index", "ResidentialMIRs")); }
// GET: NonResidentialMIRs/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NonResidentialMIR nonResidentialMIR = db.NonResidentialMIRs .Include(s => s.Subcontractor) .SingleOrDefault(a => a.Id == id); if (nonResidentialMIR == null) { return(HttpNotFound()); } return(View(nonResidentialMIR)); }
public ActionResult Edit([Bind(Include = "Id,SubcontractorId,TotBedNights,TotA2AEnrollment,TotOverallServed,TotA2ABedNights,SubmittedDate,MA2Apercent,ClientsJobEduServ,ParticipatingFathers,TotEduClasses,TotClientsinEduClasses,TotCaseHrs,TotClientsCaseHrs,TotOtherClasses,Year,Months")] NonResidentialMIR nonResidentialMIR) { if (ModelState.IsValid) { nonResidentialMIR.SubmittedDate = DateTime.Now; db.Entry(nonResidentialMIR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "ResidentialMIRs")); } var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList(); ViewBag.Year = new SelectList(datelist); ViewBag.SubcontractorId = new SelectList(db.SubContractors, "SubcontractorId", "OrgName"); return(View(nonResidentialMIR)); }
// GET: NonResidentialMIRs/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NonResidentialMIR nonResidentialMIR = db.NonResidentialMIRs.Find(id); if (nonResidentialMIR == null) { return(HttpNotFound()); } var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList(); ViewBag.Year = new SelectList(datelist); ViewBag.SubcontractorId = new SelectList(db.SubContractors.Where(a => a.SubcontractorId == nonResidentialMIR.SubcontractorId), "SubcontractorId", "OrgName"); return(View(nonResidentialMIR)); }