// GET: PerformNoteRepairs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PerformNoteRepair performNoteRepair = db.PerformNoteRepairs.Find(id); if (performNoteRepair == null) { return(HttpNotFound()); } if (User.Identity.Name == "") { throw new Exception("Access not denid"); } if (db.StaffPersons.Where(p => p.UserName == User.Identity.Name).First().AccessType != "Administrator" && ((performNoteRepair.CreateUserName != User.Identity.Name))) { throw new Exception("Access not denid"); } return(View(performNoteRepair)); }
// GET: PerformNoteRepairs/Create public ActionResult Create() { if (User.Identity.Name == "") { throw new Exception("Access not denid"); } PerformNoteRepair performNoteRepair = new PerformNoteRepair(); performNoteRepair.DateTimeStart = performNoteRepair.DateTimeEnd = new MDTime().GetCurrentTime(); return(View(performNoteRepair)); }
public ActionResult DeleteConfirmed(int id) { PerformNoteRepair performNoteRepair = db.PerformNoteRepairs.Find(id); if (User.Identity.Name == "") { throw new Exception("Access not denid"); } if (db.StaffPersons.Where(p => p.UserName == User.Identity.Name).First().AccessType != "Administrator" && ((performNoteRepair.CreateUserName != User.Identity.Name))) { throw new Exception("Access not denid"); } db.PerformNoteRepairs.Remove(performNoteRepair); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,DateTimeStart,DateTimeEnd,RepairObjectText,TypeOfFaultText,RepairActionText,ReportText,IsCompleted")] PerformNoteRepair performNoteRepair) { if (User.Identity.Name == "") { throw new Exception("Access not denid"); } performNoteRepair.CreateUserName = performNoteRepair.ModifyUserName = User.Identity.Name; performNoteRepair.CreateDate = performNoteRepair.ModifyDate = DateTime.UtcNow; if (ModelState.IsValid) { db.PerformNoteRepairs.Add(performNoteRepair); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(performNoteRepair)); }
public ActionResult Edit([Bind(Include = "Id,DateTimeStart,DateTimeEnd,RepairObjectText,TypeOfFaultText,RepairActionText,ReportText,IsCompleted,CreateUserName,CreateDate")] PerformNoteRepair performNoteRepair) { if (User.Identity.Name == "") { throw new Exception("Access not denid"); } if (db.StaffPersons.Where(p => p.UserName == User.Identity.Name).First().AccessType != "Administrator" && ((performNoteRepair.CreateUserName != User.Identity.Name))) { throw new Exception("Access not denid"); } performNoteRepair.ModifyUserName = User.Identity.Name; performNoteRepair.ModifyDate = DateTime.UtcNow; if (ModelState.IsValid) { db.Entry(performNoteRepair).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(performNoteRepair)); }