public ActionResult Create([Bind(Include = "Project_ID,Property_ID,User_ID,Proj_Code,Project_Desc,Proj_budget_Requested,Proj_budget_Approved,Proj_funds_issued,Proj_Act_Cost,Status")] Work work) { try { if (ModelState.IsValid) { db.Opwwork2.Add(work); db.SaveChanges(); if (work.User_ID == 8) { return(RedirectToAction("CWDashBoard", "Authorisation")); } else if (work.User_ID == 1) { return(RedirectToAction("EWDashBoard", "Authorisation")); } //return RedirectToAction("Index"); //return Redirect(Request.UrlReferrer.ToString()); // Can we have just one Create Function - CJC } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } ViewBag.User_ID = new SelectList(db.Opwauthorisation2, "User_ID", "User_Name", work.User_ID); return(View(work)); }
public ActionResult Create([Bind(Include = "Property_ID,OPW_Building_Code,Address,County,Type,Cost_Centre,Team,WorkId")] Property property) { if (ModelState.IsValid) { db.Opwproperty2.Add(property); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(property)); }
public ActionResult Create([Bind(Include = "User_ID,User_Name,User_Password,Email,Company,Usersect,Usersectcode,User_Approval_Limit,WorkId")] Authorisation authorisation) { if (ModelState.IsValid) { db.Opwauthorisation2.Add(authorisation); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(authorisation)); }
public ActionResult Create([Bind(Include = "User_ID,User_Name,User_Password,Email,Company,Usersect,Usersectcode,User_Approval_Limit,WorkId")] Authorisation authorisation) { try { if (authorisation.Usersect == User_Section.MandE_Works) { authorisation.Usersectcode = User_Section_Code.E30_ZS_34; authorisation.User_Approval_Limit = 0; } else if (authorisation.Usersect == User_Section.Elective_Works) { authorisation.Usersectcode = User_Section_Code.k00_ZS_34; authorisation.User_Approval_Limit = 0; } else if (authorisation.Usersect == User_Section.Capital_works) { authorisation.Usersectcode = User_Section_Code.J10_ZS_34; authorisation.User_Approval_Limit = 0; } else if (authorisation.Usersect == User_Section.Storage) { authorisation.Usersectcode = User_Section_Code.L00_ZH_34; authorisation.User_Approval_Limit = 0; } else if (authorisation.Usersect == User_Section.Admin) { authorisation.Usersectcode = User_Section_Code.Admin; authorisation.User_Approval_Limit = 999999999; } else if (authorisation.Usersect == User_Section.Accommodation) { authorisation.Usersectcode = User_Section_Code.FMU1; authorisation.User_Approval_Limit = 50000; } } catch (Exception e) { System.Console.WriteLine(e); } if (ModelState.IsValid) { db.Opwauthorisation2.Add(authorisation); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(authorisation)); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // DEASP - Actions Controllers //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // GET / POST: Work/Edit/5 - Approve Project //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public ActionResult Approve(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Work work = db.Opwwork2.Find(id); if (work == null) { return(HttpNotFound()); } if (ModelState.IsValid) { work.Status = Status.Approved; work.Proj_budget_Approved = work.Proj_budget_Requested; db.Entry(work).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AccomWorksforApproval")); } ViewBag.User_ID = new SelectList(db.Opwauthorisation2, "User_ID", "User_Name", work.User_ID); return(View(work)); }