public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address")] LabModel labModel)
        {
            if (id != labModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    cntx.Update(labModel);
                    await cntx.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LabModelExists(labModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(labModel));
        }
Ejemplo n.º 2
0
        public async Task <object> Add(LabInputModel labInputModel)
        {
            var groupModel = await _context.Group.FindAsync(labInputModel.GroupId);

            if ((await getLabIdByName(labInputModel.Name) > 0) || groupModel == null)
            {
                return("bad request");
            }
            var model = new LabModel
            {
                GroupId     = labInputModel.GroupId,
                Name        = labInputModel.Name,
                DateTime    = labInputModel.DateTime,
                Title       = labInputModel.Title,
                Description = labInputModel.Description,
                Curricula   = labInputModel.Curricula,
            };

            _context.Lab.Add(model);
            try
            {
                await _context.SaveChangesAsync();
            } catch (Exception)
            {
                return("bad request");
            }
            return(model);
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Address")] LabModel labModel)
        {
            if (ModelState.IsValid)
            {
                cntx.Add(labModel);
                await cntx.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(labModel));
        }
Ejemplo n.º 4
0
        public ActionResult Index(string dfn, LabResultType labType, bool pregFilter, string page)
        {
            // *** Create the model ***
            LabModel model = new LabModel();

            // *** Set the patient ***
            model.Patient = this.CurrentPatient;

            // *** Get the page value ***
            int pageVal = this.GetPage(page);

            // *** Create date range dates ***
            DateTime fromDate = DateTime.MinValue;
            DateTime toDate   = DateTime.MinValue;

            // *** Add the filters to the model ***
            model.LabTypeFilter = labType.ToString();

            PregnancyDetails pregDetails = null;

            PregnancyResult pregResult = this.DashboardRepository.Pregnancy.GetCurrentOrMostRecentPregnancy(dfn);

            if (pregResult.Success)
            {
                if (pregResult.Pregnancy != null)
                {
                    pregDetails = pregResult.Pregnancy;
                }
            }

            if (pregDetails != null)
            {
                if (pregDetails.RecordType == Data.Models.Pregnancy.PregnancyRecordType.Current)
                {
                    model.PregnancyFilterDescription = "Current Pregnancy";
                }
                else
                {
                    model.PregnancyFilterDescription = "Most Recent Pregnancy";
                }

                if (pregFilter)
                {
                    // *** Set the date range dates ***
                    fromDate = pregDetails.StartDate;
                    toDate   = pregDetails.EndDate;

                    // *** Create an approximate date/time for fromDate if needed ***
                    if (fromDate == DateTime.MinValue)
                    {
                        if (toDate != DateTime.MinValue)
                        {
                            fromDate = toDate.AddDays(-280);
                        }
                    }

                    model.FilteredByPregnancy = true;
                }

                model.CanFilterByPregnancy = true;
            }
            else
            {
                model.PregnancyFilterDescription = "Current Pregnancy";
                model.CanFilterByPregnancy       = false;
                model.FilteredByPregnancy        = false;
            }

            // *** Get the list of labs ***
            LabItemsResult labsResult = this.DashboardRepository.Labs.GetList(dfn, labType, pregFilter, fromDate, toDate, pageVal, LabItemsPerPage);

            if (!labsResult.Success)
            {
                this.Error(labsResult.Message);
            }
            else
            if (labsResult.Labs == null)
            {
                model.Items = new List <LabItem>();
            }
            else
            {
                // *** Add lab items ***
                model.Items = labsResult.Labs;

                // *** Paging ***
                model.Paging.SetPagingData(LabItemsPerPage, pageVal, labsResult.TotalResults);
                model.Paging.BaseUrl = Url.Action("Index", new { dfn = dfn, labtype = labType, pregFilter = pregFilter, page = "" });
            }

            return(View(model));
        }
Ejemplo n.º 5
0
        public IActionResult PassUsingModel()
        {
            LabModel model = Calculate();

            return(View(model));
        }