public void addLab(string newLabType, string newLabName, int newLabResult, string newLabUnit, string newLabResultStatus, Guid?id)
 {
     if (newLabName != string.Empty && newLabName != null && id != null && id != Guid.Empty)
     {
         LaboratoryService _laboratoryService = new LaboratoryService();
         Laboratory        laboratory         = _laboratoryService.get(id);
         if (laboratory == null)
         {
             return;
         }
         Lab lab = new Lab()
         {
             id           = Guid.NewGuid(),
             LabType      = newLabType,
             Name         = newLabName,
             result       = newLabResult,
             Unit         = newLabUnit,
             ResultStatus = newLabResultStatus,
             LaboratoryId = id
         };
         LabService _labService = new LabService();
         _labService.add(lab);
         Response.Write("1");
     }
     else
     {
         Response.Write("9");
     }
 }
        public ActionResult Remove(int?id)
        {
            var applicationService = new LaboratoryService(context);
            var operationResult    = applicationService.remove(id);

            return(RedirectToAction("Index"));
        }
        public ActionResult AddOrModifyLaboratory(int?id)
        {
            var administrationService = new LaboratoryService(context);

            ViewBag.States = getStatesWithLaboratories();
            return(View(administrationService.getInputModelForId(id)));
        }
        // GET: Admin/Laboratory
        public async Task <ActionResult> Index()
        {
            var applicationService = new LaboratoryService(context);
            var laboratories       = await applicationService.getLaboratories();

            return(View(laboratories));
        }
        public void Initialize()
        {
            string connectionString = "Server=den1.mssql7.gear.host; Database=dotnottests;User Id=dotnottests;Password=Ky4DwF?7-YQY;";
            var    builder          = new DbContextOptionsBuilder <ScheduleContext>().UseSqlServer(connectionString);

            context           = new ScheduleContext(builder.Options);
            laboratoryService = new LaboratoryService(context, context);
        }
        private static ILaboratoryService GetLabServiceForLabOrdersTests(Common.Constants.ResultType expectedResultType)
        {
            List <LaboratoryOrder> labOrders = new List <LaboratoryOrder>()
            {
                new LaboratoryOrder()
                {
                    Id              = Guid.NewGuid(),
                    Location        = "Vancouver",
                    PHN             = "001",
                    MessageDateTime = DateTime.Now,
                    MessageID       = MockedMessageID + "1",
                    ReportAvailable = true,
                },
                new LaboratoryOrder()
                {
                    Id              = Guid.NewGuid(),
                    Location        = "Vancouver",
                    PHN             = "002",
                    MessageDateTime = DateTime.Now,
                    MessageID       = MockedMessageID + "2",
                    ReportAvailable = false,
                },
            };
            RequestResult <IEnumerable <LaboratoryOrder> > delegateResult = new RequestResult <IEnumerable <LaboratoryOrder> >()
            {
                ResultStatus    = expectedResultType,
                PageSize        = 100,
                PageIndex       = 1,
                ResourcePayload = labOrders,
            };

            var mockLaboratoryDelegate = new Mock <ILaboratoryDelegate>();

            mockLaboratoryDelegate.Setup(s => s.GetLaboratoryOrders(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).Returns(Task.FromResult(delegateResult));

            var mockLaboratoryDelegateFactory = new Mock <ILaboratoryDelegateFactory>();

            mockLaboratoryDelegateFactory.Setup(s => s.CreateInstance()).Returns(mockLaboratoryDelegate.Object);

            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var context = new DefaultHttpContext()
            {
                Connection =
                {
                    RemoteIpAddress = IPAddress.Parse(IpAddress),
                },
            };

            context.Request.Headers.Add("Authorization", "MockJWTHeader");
            mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);

            ILaboratoryService service = new LaboratoryService(
                new Mock <ILogger <LaboratoryService> >().Object,
                mockHttpContextAccessor.Object,
                mockLaboratoryDelegateFactory.Object);

            return(service);
        }
Exemple #7
0
        async void Launch_BarcodeSearch()
        {
            var result = await BarCodes.Instance.Read();

            if (!result.Success)
            {
                await this.DisplayAlert("Desculpe ! Falha! ", "Não foi possível ler o código de barras!", "OK");
            }
            else
            {
                LaboratoryService laboratoryService = new LaboratoryService();
                var laboratory = laboratoryService.GetByLaboratoryCode(result.Code);
                InformacoesParaPagina(await laboratory);
            }
        }
        public ActionResult AddOrUpdate(LaboratoryInputModel inputData)
        {
            var applicationService = new LaboratoryService(context);
            var result             = applicationService.addOrUpdateLaboratory(inputData);

            if (result.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.States = getStatesWithLaboratories();

            ViewBag.Errors = result.Errors;
            return(View("AddOrModifyLaboratory", inputData));
        }
        public void GetLabReport()
        {
            LaboratoryReport labReport = new LaboratoryReport()
            {
                Report    = MockedReportContent,
                MediaType = "mockedMediaType",
                Encoding  = "mockedEncoding",
            };
            RequestResult <LaboratoryReport> delegateResult = new RequestResult <LaboratoryReport>()
            {
                ResultStatus    = Common.Constants.ResultType.Success,
                PageSize        = 100,
                PageIndex       = 1,
                ResourcePayload = labReport,
            };

            var mockLaboratoryDelegate = new Mock <ILaboratoryDelegate>();

            mockLaboratoryDelegate.Setup(s => s.GetLabReport(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(delegateResult));

            var mockLaboratoryDelegateFactory = new Mock <ILaboratoryDelegateFactory>();

            mockLaboratoryDelegateFactory.Setup(s => s.CreateInstance()).Returns(mockLaboratoryDelegate.Object);

            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var context = new DefaultHttpContext()
            {
                Connection =
                {
                    RemoteIpAddress = IPAddress.Parse(IpAddress),
                },
            };

            context.Request.Headers.Add("Authorization", "MockJWTHeader");
            mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);

            ILaboratoryService service = new LaboratoryService(
                new Mock <ILogger <LaboratoryService> >().Object,
                mockHttpContextAccessor.Object,
                mockLaboratoryDelegateFactory.Object);
            var actualResult = service.GetLabReport(Guid.NewGuid(), string.Empty, BearerToken);

            Assert.True(actualResult.Result.ResultStatus == Common.Constants.ResultType.Success);
            Assert.True(actualResult.Result !.ResourcePayload !.Report == MockedReportContent);
        }