public TxtServiceSamplingPlanSamplingPlan(TaskRunnerBaseService taskRunnerBaseService) { _TaskRunnerBaseService = taskRunnerBaseService; _SamplingPlanService = new SamplingPlanService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User); _SamplingPlanSubsectorService = new SamplingPlanSubsectorService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User); _SamplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User); _MWQMSubsectorService = new MWQMSubsectorService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User); }
public void SamplingPlan_Controller_Put_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { SamplingPlanController samplingPlanController = new SamplingPlanController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(samplingPlanController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanController.DatabaseType); SamplingPlan samplingPlanLast = new SamplingPlan(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; SamplingPlanService samplingPlanService = new SamplingPlanService(query, db, ContactID); samplingPlanLast = (from c in db.SamplingPlans select c).FirstOrDefault(); } // ok with SamplingPlan info IHttpActionResult jsonRet = samplingPlanController.GetSamplingPlanWithID(samplingPlanLast.SamplingPlanID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <SamplingPlan> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlan>; SamplingPlan samplingPlanRet = Ret.Content; Assert.AreEqual(samplingPlanLast.SamplingPlanID, samplingPlanRet.SamplingPlanID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Put to return success IHttpActionResult jsonRet2 = samplingPlanController.Put(samplingPlanRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <SamplingPlan> samplingPlanRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlan>; Assert.IsNotNull(samplingPlanRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Put to return CSSPError because SamplingPlanID of 0 does not exist samplingPlanRet.SamplingPlanID = 0; IHttpActionResult jsonRet3 = samplingPlanController.Put(samplingPlanRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); OkNegotiatedContentResult <SamplingPlan> samplingPlanRet3 = jsonRet3 as OkNegotiatedContentResult <SamplingPlan>; Assert.IsNull(samplingPlanRet3); BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest3); } } }
public IHttpActionResult GetSamplingPlanList([FromUri] string lang = "en", [FromUri] int skip = 0, [FromUri] int take = 200, [FromUri] string asc = "", [FromUri] string desc = "", [FromUri] string where = "", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SamplingPlanService samplingPlanService = new SamplingPlanService(new Query() { Lang = lang }, db, ContactID);
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); _AppTaskService = new AppTaskService(LanguageRequest, User); _SamplingPlanService = new SamplingPlanService(LanguageRequest, User); _SamplingPlanEmailService = new SamplingPlanEmailService(LanguageRequest, User); _SamplingPlanSubsectorService = new SamplingPlanSubsectorService(LanguageRequest, User); _SamplingPlanSubsectorSiteService = new SamplingPlanSubsectorSiteService(LanguageRequest, User); _TVFileService = new TVFileService(LanguageRequest, User); _LabSheetService = new LabSheetService(LanguageRequest, User); _BaseEnumService = new BaseEnumService(LanguageRequest); }
public IHttpActionResult GetSamplingPlanWithID([FromUri] int SamplingPlanID, [FromUri] string lang = "en", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SamplingPlanService samplingPlanService = new SamplingPlanService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); samplingPlanService.Query = samplingPlanService.FillQuery(typeof(SamplingPlan), lang, 0, 1, "", "", extra); if (samplingPlanService.Query.Extra == "A") { SamplingPlanExtraA samplingPlanExtraA = new SamplingPlanExtraA(); samplingPlanExtraA = samplingPlanService.GetSamplingPlanExtraAWithSamplingPlanID(SamplingPlanID); if (samplingPlanExtraA == null) { return(NotFound()); } return(Ok(samplingPlanExtraA)); } else if (samplingPlanService.Query.Extra == "B") { SamplingPlanExtraB samplingPlanExtraB = new SamplingPlanExtraB(); samplingPlanExtraB = samplingPlanService.GetSamplingPlanExtraBWithSamplingPlanID(SamplingPlanID); if (samplingPlanExtraB == null) { return(NotFound()); } return(Ok(samplingPlanExtraB)); } else { SamplingPlan samplingPlan = new SamplingPlan(); samplingPlan = samplingPlanService.GetSamplingPlanWithSamplingPlanID(SamplingPlanID); if (samplingPlan == null) { return(NotFound()); } return(Ok(samplingPlan)); } } }
public void SamplingPlan_Controller_GetSamplingPlanWithID_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { SamplingPlanController samplingPlanController = new SamplingPlanController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(samplingPlanController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanController.DatabaseType); SamplingPlan samplingPlanFirst = new SamplingPlan(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SamplingPlanService samplingPlanService = new SamplingPlanService(new Query(), db, ContactID); samplingPlanFirst = (from c in db.SamplingPlans select c).FirstOrDefault(); } // ok with SamplingPlan info IHttpActionResult jsonRet = samplingPlanController.GetSamplingPlanWithID(samplingPlanFirst.SamplingPlanID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <SamplingPlan> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlan>; SamplingPlan samplingPlanRet = Ret.Content; Assert.AreEqual(samplingPlanFirst.SamplingPlanID, samplingPlanRet.SamplingPlanID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Not Found IHttpActionResult jsonRet2 = samplingPlanController.GetSamplingPlanWithID(0); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <SamplingPlan> samplingPlanRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlan>; Assert.IsNull(samplingPlanRet2); NotFoundResult notFoundRequest = jsonRet2 as NotFoundResult; Assert.IsNotNull(notFoundRequest); } } }
public PartialViewResult _LabSheetsHistory(int SamplingPlanID) { ViewBag.SamplingPlanController = _SamplingPlanController; ViewBag.AdminContactModelList = null; ViewBag.IsSamplingPlanner = false; ViewBag.LabSheetModelList = null; ViewBag.SamplingPlanID = SamplingPlanID; ViewBag.LabSheetModelList = null; ViewBag.LabSheetSiteMonitoredCountsList = null; List <LabSheetModel> labSheetModelList = new List <LabSheetModel>(); SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User); LabSheetService labSheetService = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMRunService mwqmRunService = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User); ContactModel contactModel = _ContactService.GetContactLoggedInDB(); SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID); if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error)) { ViewBag.IsSamplingPlanner = false; if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString())) { ViewBag.IsSamplingPlanner = true; } else { List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB(); ViewBag.AdminContactModelList = adminContactModelList; } labSheetModelList = labSheetService.GetLabSheetModelListWithSamplingPlanIDDB(SamplingPlanID); ViewBag.LabSheetModelList = labSheetModelList; List <LabSheetSiteMonitoredCounts> labSheetSiteMonitoredCountsList = labSheetService.GetLabSheetIDListAndCountSamplesWithSamplingPlanIDDB(SamplingPlanID); ViewBag.LabSheetSiteMonitoredCountsList = labSheetSiteMonitoredCountsList; } return(PartialView()); }
public IHttpActionResult Delete([FromBody] SamplingPlan samplingPlan, [FromUri] string lang = "en") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SamplingPlanService samplingPlanService = new SamplingPlanService(new Query() { Language = (lang == "fr" ? LanguageEnum.fr : LanguageEnum.en) }, db, ContactID); if (!samplingPlanService.Delete(samplingPlan)) { return(BadRequest(String.Join("|||", samplingPlan.ValidationResults))); } else { samplingPlan.ValidationResults = null; return(Ok(samplingPlan)); } } }
public void SamplingPlan_Controller_GetSamplingPlanList_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { SamplingPlanController samplingPlanController = new SamplingPlanController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(samplingPlanController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanController.DatabaseType); SamplingPlan samplingPlanFirst = new SamplingPlan(); int count = -1; Query query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { SamplingPlanService samplingPlanService = new SamplingPlanService(query, db, ContactID); samplingPlanFirst = (from c in db.SamplingPlans select c).FirstOrDefault(); count = (from c in db.SamplingPlans select c).Count(); count = (query.Take > count ? count : query.Take); } // ok with SamplingPlan info IHttpActionResult jsonRet = samplingPlanController.GetSamplingPlanList(); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <List <SamplingPlan> > ret = jsonRet as OkNegotiatedContentResult <List <SamplingPlan> >; Assert.AreEqual(samplingPlanFirst.SamplingPlanID, ret.Content[0].SamplingPlanID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); List <SamplingPlan> samplingPlanList = new List <SamplingPlan>(); count = -1; query = new Query(); using (CSSPDBContext db = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { SamplingPlanService samplingPlanService = new SamplingPlanService(query, db, ContactID); samplingPlanList = (from c in db.SamplingPlans select c).OrderBy(c => c.SamplingPlanID).Skip(0).Take(2).ToList(); count = (from c in db.SamplingPlans select c).Count(); } if (count > 0) { query.Skip = 0; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with SamplingPlan info jsonRet = samplingPlanController.GetSamplingPlanList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet); ret = jsonRet as OkNegotiatedContentResult <List <SamplingPlan> >; Assert.AreEqual(samplingPlanList[0].SamplingPlanID, ret.Content[0].SamplingPlanID); Assert.AreEqual((count > query.Take ? query.Take : count), ret.Content.Count); if (count > 1) { query.Skip = 1; query.Take = 5; count = (query.Take > count ? query.Take : count); // ok with SamplingPlan info IHttpActionResult jsonRet2 = samplingPlanController.GetSamplingPlanList(query.Language.ToString(), query.Skip, query.Take); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <List <SamplingPlan> > ret2 = jsonRet2 as OkNegotiatedContentResult <List <SamplingPlan> >; Assert.AreEqual(samplingPlanList[1].SamplingPlanID, ret2.Content[0].SamplingPlanID); Assert.AreEqual((count > query.Take ? query.Take : count), ret2.Content.Count); } } } } }
public void SamplingPlan_Controller_Delete_Test() { foreach (LanguageEnum LanguageRequest in AllowableLanguages) { foreach (int ContactID in new List <int>() { AdminContactID }) //, TestEmailValidatedContactID, TestEmailNotValidatedContactID }) { SamplingPlanController samplingPlanController = new SamplingPlanController(DatabaseTypeEnum.SqlServerTestDB); Assert.IsNotNull(samplingPlanController); Assert.AreEqual(DatabaseTypeEnum.SqlServerTestDB, samplingPlanController.DatabaseType); SamplingPlan samplingPlanLast = new SamplingPlan(); using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { Query query = new Query(); query.Language = LanguageRequest; query.Asc = ""; query.Desc = ""; SamplingPlanService samplingPlanService = new SamplingPlanService(query, db, ContactID); samplingPlanLast = (from c in db.SamplingPlans select c).FirstOrDefault(); } // ok with SamplingPlan info IHttpActionResult jsonRet = samplingPlanController.GetSamplingPlanWithID(samplingPlanLast.SamplingPlanID); Assert.IsNotNull(jsonRet); OkNegotiatedContentResult <SamplingPlan> Ret = jsonRet as OkNegotiatedContentResult <SamplingPlan>; SamplingPlan samplingPlanRet = Ret.Content; Assert.AreEqual(samplingPlanLast.SamplingPlanID, samplingPlanRet.SamplingPlanID); BadRequestErrorMessageResult badRequest = jsonRet as BadRequestErrorMessageResult; Assert.IsNull(badRequest); // Post to return newly added SamplingPlan samplingPlanRet.SamplingPlanID = 0; samplingPlanRet.SamplingPlanName = samplingPlanRet.SamplingPlanName.Replace(".txt", "_a.txt"); samplingPlanController.Request = new System.Net.Http.HttpRequestMessage(); samplingPlanController.Request.RequestUri = new System.Uri("http://localhost:5000/api/samplingPlan"); IHttpActionResult jsonRet3 = samplingPlanController.Post(samplingPlanRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet3); CreatedNegotiatedContentResult <SamplingPlan> samplingPlanRet3 = jsonRet3 as CreatedNegotiatedContentResult <SamplingPlan>; Assert.IsNotNull(samplingPlanRet3); SamplingPlan samplingPlan = samplingPlanRet3.Content; BadRequestErrorMessageResult badRequest3 = jsonRet3 as BadRequestErrorMessageResult; Assert.IsNull(badRequest3); // Delete to return success IHttpActionResult jsonRet2 = samplingPlanController.Delete(samplingPlanRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet2); OkNegotiatedContentResult <SamplingPlan> samplingPlanRet2 = jsonRet2 as OkNegotiatedContentResult <SamplingPlan>; Assert.IsNotNull(samplingPlanRet2); BadRequestErrorMessageResult badRequest2 = jsonRet2 as BadRequestErrorMessageResult; Assert.IsNull(badRequest2); // Delete to return CSSPError because SamplingPlanID of 0 does not exist samplingPlanRet.SamplingPlanID = 0; IHttpActionResult jsonRet4 = samplingPlanController.Delete(samplingPlanRet, LanguageRequest.ToString()); Assert.IsNotNull(jsonRet4); OkNegotiatedContentResult <SamplingPlan> samplingPlanRet4 = jsonRet4 as OkNegotiatedContentResult <SamplingPlan>; Assert.IsNull(samplingPlanRet4); BadRequestErrorMessageResult badRequest4 = jsonRet4 as BadRequestErrorMessageResult; Assert.IsNotNull(badRequest4); } } }
public PartialViewResult _LabSheetsTranferred(int SamplingPlanID) { ViewBag.SamplingPlanController = _SamplingPlanController; ViewBag.AdminContactModelList = null; ViewBag.IsSamplingPlanner = false; ViewBag.LabSheetModelAndA1SheetList = null; ViewBag.LastAnalyzeMethod = AnalyzeMethodEnum.Error; ViewBag.LastSampleMatrix = SampleMatrixEnum.Error; ViewBag.LastLaboratory = LaboratoryEnum.Error; ViewBag.MWQMSampleModelList = new List <MWQMSampleModel>(); ViewBag.SubsectorMWQMSiteModelList = new List <SubsectorMWQMSiteModel>(); ViewBag.SamplingPlanModel = null; ViewBag.LabSheetSiteMonitoredCountsList = null; List <LabSheetModelAndA1Sheet> labSheetModelAndA1SheetList = new List <LabSheetModelAndA1Sheet>(); SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User); LabSheetService labSheetService = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMRunService mwqmRunService = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMSampleService mwqmSampleService = new MWQMSampleService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMSiteService mwqmSiteService = new MWQMSiteService(_TVItemService.LanguageRequest, _TVItemService.User); ContactModel contactModel = _ContactService.GetContactLoggedInDB(); SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID); if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error)) { ViewBag.SamplingPlanModel = SamplingPlanModel; ViewBag.IsSamplingPlanner = false; if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString())) { ViewBag.IsSamplingPlanner = true; } else { List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB(); ViewBag.AdminContactModelList = adminContactModelList; } List <LabSheetModel> labSheetModelList = labSheetService.GetLabSheetModelListWithSamplingPlanIDAndLabSheetStatusDB(SamplingPlanID, LabSheetStatusEnum.Transferred); foreach (LabSheetModel labSheetModel in labSheetModelList) { LabSheetModelAndA1Sheet labSheetModelAndA1Sheet = new LabSheetModelAndA1Sheet(); labSheetModelAndA1Sheet.LabSheetModel = labSheetModel; labSheetModelAndA1Sheet.LabSheetA1Sheet = labSheetService.ParseLabSheetA1WithLabSheetID(labSheetModel.LabSheetID); labSheetModelAndA1SheetList.Add(labSheetModelAndA1Sheet); } ViewBag.LabSheetModelAndA1SheetList = labSheetModelAndA1SheetList; if (labSheetModelAndA1SheetList.Count > 0) { MWQMRunModel mwqmRunModelLast = mwqmRunService.GetMWQMRunModelLastWithSubsectorTVItemIDDB(labSheetModelAndA1SheetList[0].LabSheetModel.SubsectorTVItemID); if (string.IsNullOrWhiteSpace(mwqmRunModelLast.Error)) { if (mwqmRunModelLast.AnalyzeMethod != null) { ViewBag.LastAnalyzeMethod = (AnalyzeMethodEnum)mwqmRunModelLast.AnalyzeMethod; } if (mwqmRunModelLast.SampleMatrix != null) { ViewBag.LastSampleMatrix = (SampleMatrixEnum)mwqmRunModelLast.SampleMatrix; } if (mwqmRunModelLast.Laboratory != null) { ViewBag.LastLaboratory = (LaboratoryEnum)mwqmRunModelLast.Laboratory; } } } List <MWQMSampleModel> mwqmSampleModelList = new List <MWQMSampleModel>(); foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList) { int Year = 0; int Month = 0; int Day = 0; if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunYear, out Year)) { if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunMonth, out Month)) { if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunDay, out Day)) { MWQMRunModel mwqmRunModelNew = new MWQMRunModel() { SubsectorTVItemID = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID, DateTime_Local = new DateTime(Year, Month, Day), RunSampleType = labSheetModelAndA1Sheet.LabSheetA1Sheet.SampleType, RunNumber = labSheetModelList[0].RunNumber, }; MWQMRunModel mwqmRunModel = mwqmRunService.GetMWQMRunModelExistDB(mwqmRunModelNew); if (string.IsNullOrWhiteSpace(mwqmRunModel.Error)) { List <MWQMSampleModel> mwqmSampleModelList2 = mwqmSampleService.GetMWQMSampleModelListWithMWQMRunTVItemIDDB(mwqmRunModel.MWQMRunTVItemID); foreach (MWQMSampleModel mwqmSampleModel in mwqmSampleModelList2) { mwqmSampleModelList.Add(mwqmSampleModel); } } } } } } ViewBag.MWQMSampleModelList = mwqmSampleModelList; if (labSheetModelAndA1SheetList.Count > 0) { List <SubsectorMWQMSiteModel> subsectorMWQMSiteModelList = new List <SubsectorMWQMSiteModel>(); foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList) { List <MWQMSiteModel> mwqmSiteModelList = mwqmSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID); subsectorMWQMSiteModelList.Add(new SubsectorMWQMSiteModel() { Subsector = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorName, MWQMSiteModelList = mwqmSiteModelList }); } ViewBag.SubsectorMWQMSiteModelList = subsectorMWQMSiteModelList; } List <LabSheetSiteMonitoredCounts> labSheetSiteMonitoredCountsList = labSheetService.GetLabSheetIDListAndCountSamplesWithSamplingPlanIDDB(SamplingPlanID); ViewBag.LabSheetSiteMonitoredCountsList = labSheetSiteMonitoredCountsList; } return(PartialView()); }
public PartialViewResult _LabSheetsHistoryDetail(int SamplingPlanID, int LabSheetID) { ViewBag.SamplingPlanController = _SamplingPlanController; ViewBag.AdminContactModelList = null; ViewBag.IsSamplingPlanner = false; ViewBag.LabSheetModelAndA1Sheet = null; ViewBag.AnalyzeMethod = AnalyzeMethodEnum.Error; ViewBag.SampleMatrix = SampleMatrixEnum.Error; ViewBag.Laboratory = LaboratoryEnum.Error; ViewBag.MWQMSiteModelList = new List <MWQMSiteModel>(); SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User); LabSheetService labSheetService = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMRunService mwqmRunService = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User); MWQMSiteService mwqmSiteService = new MWQMSiteService(_TVItemService.LanguageRequest, _TVItemService.User); ContactModel contactModel = _ContactService.GetContactLoggedInDB(); SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID); if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error)) { ViewBag.IsSamplingPlanner = false; if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString())) { ViewBag.IsSamplingPlanner = true; } else { List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB(); ViewBag.AdminContactModelList = adminContactModelList; } LabSheetModel labSheetModel = labSheetService.GetLabSheetModelWithLabSheetIDDB(LabSheetID); LabSheetModelAndA1Sheet labSheetModelAndA1Sheet = new LabSheetModelAndA1Sheet(); labSheetModelAndA1Sheet.LabSheetModel = labSheetModel; labSheetModelAndA1Sheet.LabSheetA1Sheet = labSheetService.ParseLabSheetA1WithLabSheetID(labSheetModel.LabSheetID); ViewBag.LabSheetModelAndA1Sheet = labSheetModelAndA1Sheet; if (labSheetModel.MWQMRunTVItemID != null) { MWQMRunModel mwqmRunModel = mwqmRunService.GetMWQMRunModelWithMWQMRunTVItemIDDB((int)labSheetModel.MWQMRunTVItemID); if (string.IsNullOrWhiteSpace(mwqmRunModel.Error)) { if (mwqmRunModel.AnalyzeMethod != null) { ViewBag.AnalyzeMethod = (AnalyzeMethodEnum)mwqmRunModel.AnalyzeMethod; } if (mwqmRunModel.SampleMatrix != null) { ViewBag.SampleMatrix = (SampleMatrixEnum)mwqmRunModel.SampleMatrix; } if (mwqmRunModel.Laboratory != null) { ViewBag.Laboratory = (LaboratoryEnum)mwqmRunModel.Laboratory; } } } List <MWQMSiteModel> mwqmSiteModelList = mwqmSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID); ViewBag.MWQMSiteModelList = mwqmSiteModelList; } return(PartialView()); }
public PartialViewResult _SamplingPlanByProvince(string Q) { SetArgs(Q); ViewBag.URLModel = urlModel; ViewBag.AdminContactModelList = null; ViewBag.IsShowMap = null; ViewBag.IsSamplingPlanner = null; ViewBag.SamplingPlanAndFilesLabSheetCountModelList = null; ViewBag.AppTaskModelList = null; ViewBag.IsShowMap = (GetURLVarShowEnumStr(URLVarShowEnum.ShowMap) == "0" ? false : true); SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User); LabSheetService labSheetService = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User); ContactModel contactModel = _ContactService.GetContactLoggedInDB(); bool IsSamplingPlanner = false; if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(urlModel.TVItemIDList[0].ToString())) { IsSamplingPlanner = true; } else { List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB(); ViewBag.AdminContactModelList = adminContactModelList; } ViewBag.IsSamplingPlanner = IsSamplingPlanner; List <SamplingPlanAndFilesLabSheetCountModel> SamplingPlanAndFilesLabSheetCountModelList = new List <SamplingPlanAndFilesLabSheetCountModel>(); if (IsSamplingPlanner) { if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(urlModel.TVItemIDList[0].ToString())) { List <SamplingPlanModel> SamplingPlanModelList = SamplingPlanService.GetSamplingPlanModelListWithProvinceTVItemIDDB(urlModel.TVItemIDList[0]); foreach (SamplingPlanModel SamplingPlanModel in SamplingPlanModelList) { SamplingPlanAndFilesLabSheetCountModel SamplingPlanAndFilesLabSheetCountModel = new SamplingPlanAndFilesLabSheetCountModel() { SamplingPlanModel = SamplingPlanModel, }; if (SamplingPlanModel.SamplingPlanFileTVItemID != null) { SamplingPlanAndFilesLabSheetCountModel.TVFileModelSamplingPlanFileTXT = _TVFileService.GetTVFileModelWithTVFileTVItemIDDB((int)SamplingPlanModel.SamplingPlanFileTVItemID); } SamplingPlanAndFilesLabSheetCountModel.LabSheetTransferredCount = labSheetService.GetLabSheetCountWithSamplingPlanIDAndLabSheetStatusDB(SamplingPlanModel.SamplingPlanID, LabSheetStatusEnum.Transferred); SamplingPlanAndFilesLabSheetCountModel.LabSheetHistoryCount = labSheetService.GetLabSheetCountWithSamplingPlanIDDB(SamplingPlanModel.SamplingPlanID); SamplingPlanAndFilesLabSheetCountModelList.Add(SamplingPlanAndFilesLabSheetCountModel); } ViewBag.SamplingPlanAndFilesLabSheetCountModelList = SamplingPlanAndFilesLabSheetCountModelList; } List <AppTaskModel> appTaskModelList = _AppTaskService.GetAppTaskModelListWithTVItemIDDB(urlModel.TVItemIDList[0]); ViewBag.AppTaskModelList = appTaskModelList; } return(PartialView()); }
public IHttpActionResult GetSamplingPlanList([FromUri] string lang = "en", [FromUri] int skip = 0, [FromUri] int take = 200, [FromUri] string asc = "", [FromUri] string desc = "", [FromUri] string where = "", [FromUri] string extra = "") { using (CSSPDBContext db = new CSSPDBContext(DatabaseType)) { SamplingPlanService samplingPlanService = new SamplingPlanService(new Query() { Lang = lang }, db, ContactID); if (extra == "A") // QueryString contains [extra=A] { samplingPlanService.Query = samplingPlanService.FillQuery(typeof(SamplingPlanExtraA), lang, skip, take, asc, desc, where, extra); if (samplingPlanService.Query.HasErrors) { return(Ok(new List <SamplingPlanExtraA>() { new SamplingPlanExtraA() { HasErrors = samplingPlanService.Query.HasErrors, ValidationResults = samplingPlanService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(samplingPlanService.GetSamplingPlanExtraAList().ToList())); } } else if (extra == "B") // QueryString contains [extra=B] { samplingPlanService.Query = samplingPlanService.FillQuery(typeof(SamplingPlanExtraB), lang, skip, take, asc, desc, where, extra); if (samplingPlanService.Query.HasErrors) { return(Ok(new List <SamplingPlanExtraB>() { new SamplingPlanExtraB() { HasErrors = samplingPlanService.Query.HasErrors, ValidationResults = samplingPlanService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(samplingPlanService.GetSamplingPlanExtraBList().ToList())); } } else // QueryString has no parameter [extra] or extra is empty { samplingPlanService.Query = samplingPlanService.FillQuery(typeof(SamplingPlan), lang, skip, take, asc, desc, where, extra); if (samplingPlanService.Query.HasErrors) { return(Ok(new List <SamplingPlan>() { new SamplingPlan() { HasErrors = samplingPlanService.Query.HasErrors, ValidationResults = samplingPlanService.Query.ValidationResults, }, }.ToList())); } else { return(Ok(samplingPlanService.GetSamplingPlanList().ToList())); } } } }