public ActionResult Create([Bind(Include = "Id,SubmittedDate,SubcontractorId,TotOverallServed,TotBedNights,TotA2AEnrollment,TotA2ABedNights,MA2Apercent,ClientsJobEduServ,ParticipatingFathers,TotEduClasses,TotClientsinEduClasses,TotCaseHrs,TotClientsCaseHrs,TotOtherClasses,Year,Month")] ResidentialMIR residentialMIR) { if (ModelState.IsValid) { var dataexist = from s in db.ResidentialMIRs where s.SubcontractorId == residentialMIR.SubcontractorId && s.Year == residentialMIR.Year && s.Month == residentialMIR.Month 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 { residentialMIR.SubmittedDate = DateTime.Now; residentialMIR.Id = Guid.NewGuid(); db.ResidentialMIRs.Add(residentialMIR); db.SaveChanges(); return(RedirectToAction("Index")); } } var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList(); ViewBag.Year = new SelectList(datelist); ViewBag.SubcontractorId = new SelectList(db.SubContractors.OrderBy(a => a.OrgName), "SubcontractorId", "OrgName", residentialMIR.SubcontractorId); return(View(residentialMIR)); }
public ActionResult DeleteConfirmed(Guid id) { ResidentialMIR residentialMIR = db.ResidentialMIRs .Include(s => s.Subcontractor) .SingleOrDefault(); db.ResidentialMIRs.Remove(residentialMIR); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: ResidentialMIRs/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ResidentialMIR residentialMIR = db.ResidentialMIRs .Include(s => s.Subcontractor) .SingleOrDefault(); if (residentialMIR == null) { return(HttpNotFound()); } return(View(residentialMIR)); }
public ActionResult Edit([Bind(Include = "Id,SubmittedDate,SubcontractorId,TotBedNights,TotOverallServed,TotA2AEnrollment,TotA2ABedNights,MA2Apercent,ClientsJobEduServ,ParticipatingFathers,TotEduClasses,TotClientsinEduClasses,TotCaseHrs,TotClientsCaseHrs,TotOtherClasses,Year,Month")] ResidentialMIR residentialMIR) { if (ModelState.IsValid) { residentialMIR.SubmittedDate = DateTime.Now; db.Entry(residentialMIR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var datelist = Enumerable.Range(System.DateTime.Now.Year - 1, 5).ToList(); ViewBag.Year = new SelectList(datelist); ViewBag.SubcontractorId = new SelectList(db.SubContractors.OrderBy(a => a.OrgName), "SubcontractorId", "OrgName", residentialMIR.SubcontractorId); return(View(residentialMIR)); }
// GET: ResidentialMIRs/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ResidentialMIR residentialMIR = db.ResidentialMIRs.Find(id); if (residentialMIR == 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 == residentialMIR.SubcontractorId).OrderBy(a => a.OrgName), "SubcontractorId", "OrgName"); return(View(residentialMIR)); }