public ActionResult Create([Bind(Include = "AllocatedBudgetId,SubcontractorId,CycleEndAdjustments,Year,AllocatedNewBudget,AllocatedOldBudget,AllocationAdjustedDate")] AllocatedBudget allocatedBudget) { if (ModelState.IsValid) { var dataexist = from s in db.AllocatedBudget.ToList() where s.SubcontractorId == allocatedBudget.SubcontractorId && s.Year == allocatedBudget.Year select s; if (dataexist.Count() >= 1) { ViewBag.error = "Allocation Budget for " + db.SubContractors.Find(allocatedBudget.SubcontractorId).OrgName + " for " + allocatedBudget.Year + " already exists."; ModelState.Clear(); } else { allocatedBudget.AllocatedBudgetId = Guid.NewGuid(); db.AllocatedBudget.Add(allocatedBudget); 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, "SubcontractorId", "OrgName", allocatedBudget.SubcontractorId); return(View(allocatedBudget)); }
public ActionResult DeleteConfirmed(Guid id) { AllocatedBudget allocatedBudget = db.AllocatedBudget.Find(id); db.AllocatedBudget.Remove(allocatedBudget); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "AllocatedBudgetId,SubcontractorId,CycleEndAdjustments,Year,AllocatedNewBudget,AllocatedOldBudget,AllocationAdjustedDate")] AllocatedBudget allocatedBudget) { if (ModelState.IsValid) { db.Entry(allocatedBudget).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubcontractorId = new SelectList(db.SubContractors, "SubcontractorId", "OrgName", allocatedBudget.SubcontractorId); return(View(allocatedBudget)); }
// GET: AllocatedBudgets/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AllocatedBudget allocatedBudget = db.AllocatedBudget.Find(id); if (allocatedBudget == null) { return(HttpNotFound()); } return(View(allocatedBudget)); }
// GET: AllocatedBudgets/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AllocatedBudget allocatedBudget = db.AllocatedBudget.Find(id); if (allocatedBudget == null) { return(HttpNotFound()); } ViewBag.SubcontractorId = new SelectList(db.SubContractors, "SubcontractorId", "OrgName", allocatedBudget.SubcontractorId); return(View(allocatedBudget)); }