public ActionResult EditEquipmentType(int id) { var equipmentType = new EquipmentType(); try { if (id < 1) { equipmentType.Error = "Invalid Selection!"; equipmentType.ErrorCode = -1; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } var myViewObj = new EquipmentTypeServices().GetEquipmentType(id); if (myViewObj == null || myViewObj.EquipmentTypeId < 1) { equipmentType.Error = "Equipment Type Information could not be retrieved."; equipmentType.ErrorCode = -1; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } Session["_equipmentType"] = myViewObj; myViewObj.ErrorCode = myViewObj.EquipmentTypeId; return(Json(myViewObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); equipmentType.Error = "An unknown error was Equipment Type Information could not be retrieved."; equipmentType.ErrorCode = -1; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } }
public ActionResult Equipments() { var equipmentTypeList = new EquipmentTypeServices().GetAllOrderedEquipmentTypes() ?? new List <EquipmentType>(); if (!equipmentTypeList.Any()) { return(RedirectToAction("EquipmentTypes", "EquipmentType")); } var equipmentList = new EquipmentServices().GetAllOrderedEquipments() ?? new List <Equipment>(); if (!equipmentList.Any()) { ViewBag.Edit = 1; ViewBag.Title = "Equipment Type SetUp"; return(View(Tuple.Create(equipmentTypeList, new List <Equipment>()))); } equipmentList.ForEach(m => { m.EquipmentLicenseStatus = m.LicenseStatus ? "Licensed" : "Unlicensed"; }); var txx = Tuple.Create(equipmentTypeList, equipmentList); ViewBag.Title = "Manage Equipments"; return(View(txx)); }
public ViewResult EquipmentTypes() { var equipmentTypeList = new EquipmentTypeServices().GetAllOrderedEquipmentTypes() ?? new List <EquipmentType>(); if (!equipmentTypeList.Any()) { ViewBag.Title = "Equipment Type SetUp"; return(View(equipmentTypeList)); } ViewBag.Title = "Manage Equipment Types"; return(View(equipmentTypeList)); }
public ActionResult AddEquipmentType(EquipmentType equipmentType) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (!ModelState.IsValid) { equipmentType.Error = "Please supply all required fields and try again"; equipmentType.ErrorCode = -1; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(equipmentType); if (wx.Code < 1) { equipmentType.Error = wx.Error; equipmentType.ErrorCode = -1; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } equipmentType.Name = equipmentType.Name; var k = new EquipmentTypeServices().AddEquipmentTypeCheckDuplicate(equipmentType); if (k < 1) { if (k == -3) { equipmentType.Error = "Equipment Type already exists"; equipmentType.ErrorCode = 0; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } equipmentType.Error = "Process Failed! Please contact the Admin or try again later"; equipmentType.ErrorCode = 0; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } equipmentType.Error = "Record was added successfully"; equipmentType.ErrorCode = 1; equipmentType.EquipmentTypeId = k; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); equipmentType.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; equipmentType.ErrorCode = 0; return(Json(equipmentType, JsonRequestBehavior.AllowGet)); } }
public ViewResult WellWorkovers(string returnMsg = null, int returnCode = 0) { try { var wellWorkOverReasonList = GetWellWorkoverReasons(); if (!wellWorkOverReasonList.Any()) { ViewBag.Title = "Well Workover Reason SetUp"; return(View("~/Views/WellWorkOverReason/WellWorkOverReasons.cshtml", wellWorkOverReasonList)); } var equipmentList = GetEquipmets(); if (!equipmentList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Equipment SetUp"; var equipmentTypeList = new EquipmentTypeServices().GetAllOrderedEquipmentTypes() ?? new List <EquipmentType>(); if (!equipmentTypeList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Equipment Type SetUp"; return(View("~/Views/EquipmentType/EquipmentTypes.cshtml", new List <EquipmentType>())); } return(View("~/Views/Equipment/Equipments.cshtml", Tuple.Create(equipmentTypeList, new List <Equipment>()))); } var wells = GetWells(); if (!wells.Any()) { ViewBag.Edit = 1; ViewBag.Title = "Well Set Up"; var wellTypeList = new WellTypeServices().GetAllOrderedWellTypes() ?? new List <WellType>(); if (!wellTypeList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Well Type Set Up"; return(View("~/Views/WellType/WellTypes.cshtml", new List <WellType>())); } var companyList = new CompanyServices().GetAllOrderedCompanies() ?? new List <Company>(); if (!companyList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "Company SetUp"; return(View("~/Views/Company/Companies.cshtml", new List <Company>())); } var wellClassList = GetWellClasses(); if (!wellClassList.Any()) { ViewBag.Edit = 0; ViewBag.Title = "well Class Set Up"; return(View("~/Views/WellClass/WellClasses.cshtml", wellClassList)); } return(View("~/Views/Well/Wells.cshtml", new WellViewModel { WellTypes = wellTypeList, Companies = companyList, WellClasses = wellClassList, Wells = new List <Well>() })); } var yearList = GetYears(); var monthList = GetMonths(); int dataCount; var wellWorkOvers = GetWellWorkovers(ItemsPerPage, PageNumber, out dataCount); if (!wellWorkOvers.Any()) { ViewBag.Edit = 1; ViewBag.Title = "Well Workover SetUp"; return(View(new WellWorkoverViewModel { WellWorkOverReasons = wellWorkOverReasonList, Equipments = equipmentList, WellObjects = wells, WellWorkOvers = new List <WellWorkover>() })); } var txx = new WellWorkoverViewModel { WellWorkOverReasons = wellWorkOverReasonList, Equipments = equipmentList, WellObjects = wells, WellWorkOvers = wellWorkOvers }; ViewBag.Title = "Manage Well Workovers"; Session["_workoverPage"] = 1; return(View(txx)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); var txx = new WellWorkoverViewModel { WellWorkOverReasons = GetWellWorkoverReasons(), Equipments = GetEquipmets(), WellObjects = GetWells(), WellWorkOvers = new List <WellWorkover>() }; ViewBag.Title = "Manage Well Workovers"; return(View(txx)); } }