public ActionResult RollerReceived(FormCollection collection) { try { var ID = Int32.Parse(collection["maintenanceID"]); Maintenance maintenance = _db.maintenances.FirstOrDefault(m => m.maintenanceID == ID); if (maintenance == null || maintenance.status != 2) { return(Redirect(Request.UrlReferrer.ToString())); } var uID = User.Identity.GetUserId(); ApplicationUser user = _db.Users.FirstOrDefault(u => u.Id == uID); maintenance.status = 4; maintenance.RubberRoller.status = RollerStatus.getStatus(2); // Set roller isRefurbish status if (maintenance.sendForRefurbished) { maintenance.RubberRoller.isRefurbished = true; } // Update roller location record bool updateLocatResult = CentralUtilities.UpdateRollerLocation(maintenance.RubberRoller, collection["rackLocation"]); int result = _db.SaveChanges(); if (result > 0 && updateLocatResult) { TempData["formStatus"] = true; TempData["formStatusMsg"] = $"<b>STATUS</b>: Roller {maintenance.RubberRoller.rollerID} has been received back from maintenance."; LogAction.log(this._controllerName, "POST", $"Roller {maintenance.RubberRoller.rollerID} has been received back from maintenance", User.Identity.GetUserId()); } else { TempData["formStatus"] = false; TempData["formStatusMsg"] = $"<b>ALERT</b>: Oops! Something went wrong. Unable to mark maintenance report #{ID} as completed."; LogAction.log(this._controllerName, "POST", $"Error marking maintenance report #{maintenance.maintenanceID} as completed", User.Identity.GetUserId()); } return(RedirectToAction("Index")); } catch (Exception ex) { TempData["formStatus"] = false; TempData["formStatusMsg"] = $"<b>ALERT</b>: Oops! Something went wrong."; LogAction.log(this._controllerName, "POST", $"Error marking maintenance report as completed {ex.Message}", User.Identity.GetUserId()); return(RedirectToAction("Index")); } }
public ActionResult ApproveReport(FormCollection collection) { try { var ID = Int32.Parse(collection["maintenanceID"]); Maintenance maintenance = _db.maintenances.FirstOrDefault(m => m.maintenanceID == ID); if (maintenance == null || maintenance.status == 2) { return(Redirect(Request.UrlReferrer.ToString())); } var uID = User.Identity.GetUserId(); ApplicationUser user = _db.Users.FirstOrDefault(u => u.Id == uID); maintenance.status = 2; maintenance.statusRemark = null; maintenance.approveDateTime = DateTime.Now; maintenance.verfiedBy = user; maintenance.RubberRoller.status = RollerStatus.getStatus(5); // Update roller location record bool updateLocatResult = CentralUtilities.UpdateRollerLocation(maintenance.RubberRoller, $"Sent to {maintenance.sendTo} for maintenance"); int result = _db.SaveChanges(); if (result > 0 && updateLocatResult) { TempData["formStatus"] = true; TempData["formStatusMsg"] = $"<b>STATUS</b>: Maintenance report #{ID} has been successfully approved."; LogAction.log(this._controllerName, "POST", $"Approved maintenance report #{maintenance.maintenanceID}", User.Identity.GetUserId()); } else { TempData["formStatus"] = false; TempData["formStatusMsg"] = $"<b>ALERT</b>: Oops! Something went wrong. Maintenance report #{ID} has not been successfully approved."; LogAction.log(this._controllerName, "POST", $"Error approving maintenance report #{maintenance.maintenanceID}", User.Identity.GetUserId()); } return(RedirectToAction("Index")); } catch (Exception ex) { TempData["formStatus"] = false; TempData["formStatusMsg"] = $"<b>ALERT</b>: Oops! Something went wrong."; LogAction.log(this._controllerName, "POST", $"Error approving maintenance report: {ex.Message}", User.Identity.GetUserId()); return(RedirectToAction("Index")); } }
public ActionResult CreateBeforeChecklist(BeforeRollerIssueChecklist beforeRollerIssueChecklist) { Schedule schedule = _db.schedules.FirstOrDefault(s => s.scheduleID == beforeRollerIssueChecklist.scheduleID); if (schedule == null) { return(RedirectToAction("CreateSearch")); } beforeRollerIssueChecklist.dateTime = DateTime.Now; beforeRollerIssueChecklist.preparedBy = getCurrentUser(); beforeRollerIssueChecklist.Schedule = schedule; _db.beforeRollerIssueChecklists.Add(beforeRollerIssueChecklist); schedule.status = ScheduleStatus.ACTIVE; // Update roller location bool updateLocatResult = CentralUtilities.UpdateRollerLocation( beforeRollerIssueChecklist.Schedule.RubberRoller, $"Operation Line {beforeRollerIssueChecklist.Schedule.operationLine}" ); int result = _db.SaveChanges(); if (result > 0 && updateLocatResult) { // Success - redirect to active operation list page TempData["formStatus"] = true; TempData["formStatusMsg"] = "<b>STATUS</b>: New operation record has been successfully added."; LogAction.log(this._controllerName, "POST", "Added new before roller issue checklist", User.Identity.GetUserId()); return(RedirectToAction("ActiveOperation")); } else { TempData["formStatus"] = false; TempData["formStatusMsg"] = "<b>ALERT</b>: Oops! Something went wrong. The before issue checklist has not been successfully added."; LogAction.log(this._controllerName, "POST", "Error adding new before roller issue checklist", User.Identity.GetUserId()); return(Redirect(Request.UrlReferrer.ToString())); } }
public ActionResult CompleteOperation(FormCollection collection) { try { // Retrieve schedule record var schedID = Int32.Parse(collection["scheduleID"]); Schedule schedule = _db.schedules.FirstOrDefault(s => s.scheduleID == schedID); if (schedule == null) { return(RedirectToAction("ActiveOperation")); } // Create new after production checklist AfterRollerProductionChecklist after = new AfterRollerProductionChecklist(); after.dateTime = DateTime.Now; after.rollerAppearance = collection["rollerAppearance"]; after.remarks = collection["remarks"]; after.scheduleID = schedule.scheduleID; after.Schedule = schedule; after.preparedBy = getCurrentUser(); after.rollerSendTo = collection["rollerSendTo"]; // Update schedule details after.Schedule.endMileage = after.Schedule.startMileage + Int32.Parse(collection["mileageRun"]); after.Schedule.endDateTime = DateTime.Parse(collection["endDT"]); after.Schedule.quantity = Int32.Parse(collection["mileageRun"]); after.Schedule.status = ScheduleStatus.COMPLETED; // Update roller details after.Schedule.RubberRoller.last_usage_date = DateTime.Now; after.Schedule.RubberRoller.status = collection["rollerSendTo"] == "Roller Room" ? RollerStatus.getStatus(RollerStatus.IN_STORE_ROOM) : RollerStatus.getStatus(RollerStatus.IN_STORE_ROOM_ON_HOLD); // Update roller location bool updateLocatResult = CentralUtilities.UpdateRollerLocation(after.Schedule.RubberRoller, (collection["rollerSendTo"] == "Roller Room" ? collection["roomLocation"] : "Roller is on-hold/Waiting to be sent to maintenance after operation")); // Add new records _db.afterRollerProductionChecklists.Add(after); int result = _db.SaveChanges(); if (result > 0 && updateLocatResult) { TempData["formStatus"] = true; TempData["formStatusMsg"] = "<b>STATUS</b>: Operation has been completed!"; LogAction.log(this._controllerName, "POST", "Added new after roller operation checklist", User.Identity.GetUserId()); return(RedirectToAction("ActiveOperation")); } else { TempData["formStatus"] = false; TempData["formStatusMsg"] = "<b>ALERT</b>: Oops! Something went wrong. The after production checklist has not been successfully added."; LogAction.log(this._controllerName, "POST", "Error adding new after roller operation checklist", User.Identity.GetUserId()); return(Redirect(Request.UrlReferrer.ToString())); } } catch (Exception ex) { TempData["formStatus"] = false; TempData["formStatusMsg"] = "<b>ALERT</b>: Oops! Something went wrong. The operation were unable to successfully marked as completed."; LogAction.log(this._controllerName, "POST", "Error: " + ex.Message, User.Identity.GetUserId()); return(RedirectToAction("ActiveOperation")); } }