public static LookupListModel <dynamic> GetLookupList(TlcConstants.TlcLookupLists type) { LookupListModel <dynamic> model = new LookupListModel <dynamic>(); model.Name = type.ToString(); string filter = null; switch (type) { case TlcConstants.TlcLookupLists.Competency: { RigCapService service = new RigCapService(); model.ModelType = typeof(CAP_CompLookupModel); model.GridLookup = true; model.DisplayField = "CompetencyTitle"; model.KeyFieldName = "CompId"; model.DataTable = service.GetListCompLookupQueryable(); model.DataTable = model.DataTable.Where(string.Format("RigId={0}", UtilitySystem.Settings.RigId)); model.Items = new List <dynamic>(); foreach (var item in model.DataTable) { model.Items.Add(item); } } break; case TlcConstants.TlcLookupLists.KSA: { RigCapService service = new RigCapService(); model.ModelType = typeof(CAP_CompKSALookupModel); model.GridLookup = true; model.MultiSelect = true; model.DisplayField = "KSATitle"; model.KeyFieldName = "KSAId"; model.DataTable = service.GetListCompKSALookupQueryable(); model.DataTable = model.DataTable.Where(string.Format("RigId={0}", UtilitySystem.Settings.RigId)); model.Items = new List <dynamic>(); foreach (var item in model.DataTable) { model.Items.Add(item); } } break; case TlcConstants.TlcLookupLists.AssessmentType: { model.ModelType = typeof(TLC_AdminModel); model.DisplayField = "AdminText"; model.KeyFieldName = "AdminText"; DropdownService service = new DropdownService(); model.Items = service.GetTLC_AdminModels("AssessmentType").Cast <dynamic>().ToList(); } break; case TlcConstants.TlcLookupLists.AssessmentMethod: { model.ModelType = typeof(TLC_AdminModel); model.DisplayField = "AdminText"; model.KeyFieldName = "AdminText"; DropdownService service = new DropdownService(); model.Items = service.GetTLC_AdminModels("AssessmentMethod").Cast <dynamic>().ToList(); } break; } model.Initialize(); return(model); }
public ActionResult CapBookReport(string passportId) { CAP_BookReportModel model = new CAP_BookReportModel(); model.CapBookEnscoLogo = HttpContext.Server.MapPath("~/Images/CapEnscoLogo.png"); model.CapBookImage1 = HttpContext.Server.MapPath("~/Images/CapBook1.png"); model.CapBookImage2 = HttpContext.Server.MapPath("~/Images/CapBook2.png"); model.CapBookTlcLogo = HttpContext.Server.MapPath("~/Images/TlcLogo.png"); model.CapBookPage1 = HttpContext.Server.MapPath("~/Images/CapBookPage1.png"); model.CapBookPage2 = HttpContext.Server.MapPath("~/Images/CapBookPage2.png"); model.CapBookPage3 = HttpContext.Server.MapPath("~/Images/CapBookPage3.png"); model.CapBookPage4 = HttpContext.Server.MapPath("~/Images/CapBookPage4.png"); model.CapBookPage5 = HttpContext.Server.MapPath("~/Images/CapBookPage5.png"); model.CapBookPage6 = HttpContext.Server.MapPath("~/Images/CapBookPage6.png"); model.CapBookPage7 = HttpContext.Server.MapPath("~/Images/CapBookPage7.png"); model.CapBookPage8 = HttpContext.Server.MapPath("~/Images/CapBookPage8.png"); model.CapBookPage9 = HttpContext.Server.MapPath("~/Images/CapBookPage9.png"); model.CapBookPage10 = HttpContext.Server.MapPath("~/Images/CapBookPage10.png"); // Get User Information LookupListModel <dynamic> lkpPosition = LookupListSystem.GetLookupList("Position"); LookupListModel <dynamic> lkpDept = LookupListSystem.GetLookupList("Department"); LookupListModel <dynamic> lkpBU = LookupListSystem.GetLookupList("BusinessUnit"); UserModel user = ServiceSystem.GetUserFromPassport(passportId); model.Passport = passportId; model.Name = user.DisplayName; model.Position = (string)lkpPosition.GetDisplayValue(user.Position); model.Department = (string)lkpPosition.GetDisplayValue(user.Department); model.BusinessUnit = (string)lkpPosition.GetDisplayValue(user.BusinessUnit); model.RigFacility = UtilitySystem.Settings.RigName; if (user.Manager != null) { UserModel manager = ServiceSystem.GetUser((int)user.Manager); if (manager != null) { model.Supervisor = manager.DisplayName; } } model.OIM = IrmaServiceSystem.GetAdminCustomValue("OIMName"); CapBookReport report = new CapBookReport(); RigCapService RigCapService = new RigCapService(); IQueryable <CAP_BookModel> capBookItems = RigCapService.GetCAPBookQueryable().Where(x => x.EnscoPassportNo == passportId).OrderBy(x => x.CompId); int compNo = 1; int ksaNo = 1; CAP_BookModel lastItem = null; foreach (CAP_BookModel item in capBookItems) { if (lastItem != null) { if (lastItem.CompId != item.CompId) { compNo++; ksaNo = 0; } ksaNo++; } item.CompetencyNumber = string.Format("{0}.0", compNo); item.KSANumber = string.Format("{0}.{1}", compNo, ksaNo); model.Items.Add(item); lastItem = (lastItem == null || lastItem.CompId != item.CompId) ? item : lastItem; } List <CAP_BookReportModel> list = new List <CAP_BookReportModel>(); list.Add(model); report.DataSource = list; Session["currentReport"] = report; return(RedirectToAction("ShowReport", "Report")); }