public async Task <IActionResult> Edit(int id, [Bind("PrescribedDrugId,Dose,Duration,Frequency,Instructions,PrescriptionId,ProprietaryId")] PrescribedDrug prescribedDrug)
        {
            if (id != prescribedDrug.PrescribedDrugId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prescribedDrug);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrescribedDrugExists(prescribedDrug.PrescribedDrugId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["PrescriptionId"] = new SelectList(_context.Prescriptions, "PrescriptionId", "Date", prescribedDrug.PrescriptionId);
            ViewData["ProprietaryId"]  = new SelectList(_context.Proprietaries, "ProprietaryId", "Name", prescribedDrug.ProprietaryId);
            return(View(prescribedDrug));
        }
Пример #2
0
        private void SendResponse(Subtransaction subtransaction)
        {
            PrescribedDrug pd = new PrescribedDrug
            {
                Id            = subtransaction.Id,
                CoveredAmount = subtransaction.AmountPaid,
            };

            string json = JsonSerializer.Serialize(pd);

            var bytes = Encoding.UTF8.GetBytes(json);

#if DEBUG
            var request = (HttpWebRequest)WebRequest.Create("https://localhost:44381/api/PrescribedDrugsAPI");
#else
            var request = (HttpWebRequest)WebRequest.Create("https://wngcsp86.intra.uwlax.edu:8080/api/PrescribedDrugsAPI");
#endif

            request.Method        = "POST";
            request.ContentLength = bytes.Length;
            request.ContentType   = "application/json";
            Stream stream = request.GetRequestStream();
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();

            WebResponse subtransactionResponse = request.GetResponse();
        }
Пример #3
0
        public async Task <ActionResult <PrescribedDrug> > PostPrescribedDrug(PrescribedDrug prescribedDrug)
        {
            PrescribedDrug found = _context.PrescribedDrugs.First(p => p.Id == prescribedDrug.Id);

            found.CoveredAmount = prescribedDrug.CoveredAmount;
            found.Returned      = true;
            _context.PrescribedDrugs.Update(found);
            await _context.SaveChangesAsync();

            Prescription          prescription    = _context.Prescriptions.First(p => p.Id == found.PrescriptionId);
            List <PrescribedDrug> prescribedDrugs = _context.PrescribedDrugs.Where(pd => pd.PrescriptionId == prescription.Id).ToList();

            if (prescribedDrugs.All(pd => pd.Returned))
            {
                prescription.SentToInsurance = true;
            }
            else
            {
                prescription.SentToInsurance = null;
            }
            _context.Prescriptions.Update(prescription);
            await _context.SaveChangesAsync();


            return(CreatedAtAction(nameof(GetPrescribedDrug), new { id = prescribedDrug.Id }, prescribedDrug));
        }
Пример #4
0
        public async Task <IActionResult> PutPrescribedDrug(int id, PrescribedDrug prescribedDrug)
        {
            if (id != prescribedDrug.Id)
            {
                return(BadRequest());
            }

            _context.Entry(prescribedDrug).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PrescribedDrugExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("PrescribedDrugId,Dose,Duration,Frequency,Instructions,PrescriptionId,ProprietaryId")] PrescribedDrug prescribedDrug)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prescribedDrug);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["PrescriptionId"] = new SelectList(_context.Prescriptions, "PrescriptionId", "Date", prescribedDrug.PrescriptionId);
            ViewData["ProprietaryId"]  = new SelectList(_context.Proprietaries, "ProprietaryId", "Name", prescribedDrug.ProprietaryId);
            return(View(prescribedDrug));
        }
        public async Task <ActionResult <PrescribedDrug> > AddPrescriptionDrugFromHealthcare(PrescribedDrug prescribedDrug)
        {
            _context.PrescribedDrugs.Add(prescribedDrug);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetPrescribedDrug), new { id = prescribedDrug.Id }, prescribedDrug));
        }