Exemplo n.º 1
0
        public async Task <IActionResult> Create(PatientExaminationViewModel patientExamVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int id = await PatientsHelper.AddPatientExAsync(patientExamVM);

                    await AppDataHelper.CheckReagentsStockAsync(_context);

                    if (!Request.Cookies.ContainsKey("reagentAlert"))
                    {
                        Response.Cookies.Append("reagentAlert", "true", new CookieOptions {
                            Expires = DateTime.Now.AddMinutes(10)
                        });
                    }
                    return(RedirectToAction(nameof(Details), new { id = id }));
                }
            }
            catch (DbUpdateException)
            {
                //Log the error
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(RedirectToAction(nameof(Create), new { id = patientExamVM.PatientID }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            await AppDataHelper.CheckReagentsStockAsync(_context);

            if (!Request.Cookies.ContainsKey("reagentAlert"))
            {
                Response.Cookies.Append("reagentAlert", "true", new CookieOptions {
                    Expires = DateTime.Now.AddMinutes(10)
                });
            }
            return(View());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            try
            {
                await PatientsHelper.CancelPatientExAsync(id);

                await AppDataHelper.CheckReagentsStockAsync(_context);

                if (!Request.Cookies.ContainsKey("reagentAlert"))
                {
                    Response.Cookies.Append("reagentAlert", "true", new CookieOptions {
                        Expires = DateTime.Now.AddMinutes(10)
                    });
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch (DbUpdateException)
            {
                return(RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true }));
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> ConfirmReceived(int id)
        {
            try
            {
                ReagentHelper.Init(_context);
                await ReagentHelper.UpdateReagentStockAsync(id);

                await AppDataHelper.CheckReagentsStockAsync(_context);

                if (!Request.Cookies.ContainsKey("reagentAlert"))
                {
                    Response.Cookies.Append("reagentAlert", "true", new CookieOptions {
                        Expires = DateTime.Now.AddMinutes(10)
                    });
                }
            }
            catch (Exception ex) when(ex is DbUpdateException || ex is DbUpdateConcurrencyException)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists, " +
                                         "see your system administrator.");
            }
            return(RedirectToAction(nameof(Index)));
        }