public ActionResult EditIncidentType(int id) { var incidentType = new IncidentType(); try { if (id < 1) { incidentType.Error = "Invalid Selection!"; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var myViewObj = new IncidentTypeServices().GetIncidentType(id); if (myViewObj == null || myViewObj.IncidentTypeId < 1) { incidentType.Error = "Incident Type Information could not be retrieved."; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } Session["_product"] = myViewObj; myViewObj.ErrorCode = myViewObj.IncidentTypeId; return(Json(myViewObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); incidentType.Error = "An unknown error was IncidentType Information could not be retrieved."; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } }
private List <IncidentType> GetIncidentTypes() { var incidentHistoryTypeList = new IncidentTypeServices().GetAllOrderedIncidentTypes() ?? new List <IncidentType>(); if (!incidentHistoryTypeList.Any()) { return(new List <IncidentType>()); } return(incidentHistoryTypeList); }
public ViewResult IncidentTypes() { var productList = new IncidentTypeServices().GetAllOrderedIncidentTypes() ?? new List <IncidentType>(); if (!productList.Any()) { ViewBag.Title = "Incident Type SetUp"; return(View(productList)); } ViewBag.Title = "Manage Incident Types"; return(View(productList)); }
public ActionResult AddIncidentType(IncidentType incidentType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (!ModelState.IsValid) { incidentType.Error = "Please supply all required fields and try again"; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(incidentType); if (wx.Code < 1) { incidentType.Error = wx.Error; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Name = incidentType.Name; var k = new IncidentTypeServices().AddIncidentTypeCheckDuplicate(incidentType); if (k < 1) { if (k == -3) { incidentType.Error = "Incident Type already exists"; incidentType.ErrorCode = -3; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Process Failed! Please contact the Admin or try again later"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Record was added successfully"; incidentType.ErrorCode = 1; incidentType.IncidentTypeId = k; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); incidentType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditIncidentType(IncidentType incidentType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (Session["_product"] == null) { incidentType.Error = "Session has expired"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var oldIncidentType = Session["_product"] as IncidentType; if (oldIncidentType == null || oldIncidentType.IncidentTypeId < 1) { incidentType.Error = "Session has expired"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } if (!ModelState.IsValid) { incidentType.Error = "Please supply all required fields and try again"; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(incidentType); if (wx.Code < 1) { incidentType.Error = wx.Error; incidentType.ErrorCode = -1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } oldIncidentType.Name = incidentType.Name; oldIncidentType.Description = incidentType.Description; var k = new IncidentTypeServices().UpdateIncidentTypeCheckDuplicate(oldIncidentType); if (k < 1) { if (k == -3) { incidentType.Error = "Incident Type already exists"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Process Failed! Please contact the Admin or try again later"; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } incidentType.Error = "Incident Type Information was successfully updated"; incidentType.ErrorCode = 1; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); incidentType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; incidentType.ErrorCode = 0; return(Json(incidentType, JsonRequestBehavior.AllowGet)); } }
private IncidentHistory ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return(null); } try { var mInfo = new IncidentHistory { Title = dv.Row["IncidentTitle"].ToString().Trim() }; //[CompanyName],[IncidentType],[IncidentTitle] GetIncidentTypeId var incidentName = dv.Row["IncidentType"].ToString().Trim(); if (string.IsNullOrEmpty(incidentName)) { msg = "Incident Name is empty"; return(null); } var incidentId = new IncidentTypeServices().GetIncidentTypeId(incidentName.Trim()); if (incidentId < 1) { msg = "Incident Information could not be processed."; return(null); } mInfo.IncidentTypeId = incidentId; var companyName = dv.Row["CompanyName"].ToString().Trim(); if (string.IsNullOrEmpty(companyName)) { msg = "Company Name is empty"; return(null); } var companyId = new CompanyServices().GetCompanyId(companyName.Trim()); if (companyId < 1) { msg = "Company Information could not be processed."; return(null); } mInfo.CompanyId = companyId; var incidentDate = dv.Row["Date(yyyy/MM/dd)"].ToString().Trim(); if (!ValidateDateCompleted(incidentDate)) { msg = "Invalid input : Incident Date"; return(null); } DateTime d1; var realDate = DateTime.TryParse(incidentDate, out d1); if (!realDate || d1.Year == 0001) { msg = "Invalid input : Incident Date"; return(null); } mInfo.IncidentDate = d1; var location = dv.Row["Location"].ToString().Trim(); if (string.IsNullOrEmpty(location.Trim())) { msg = "Incident Location is empty."; return(null); } mInfo.Location = location; var description = dv.Row["Description"].ToString().Trim(); if (string.IsNullOrEmpty(description.Trim())) { msg = "Incident Description is empty."; return(null); } mInfo.Description = description; var incidentReporter = dv.Row["ReportedBy"].ToString().Trim(); if (!string.IsNullOrEmpty(incidentReporter.Trim())) { mInfo.ReportedBy = incidentReporter; } return(mInfo); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(null); } }