Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MedicationTypeId,Name")] MedicationType medicationType)
        {
            if (id != medicationType.MedicationTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicationType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicationTypeExists(medicationType.MedicationTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicationType));
        }
        public IHttpActionResult PutMedicationType(int id, MedicationType medicationType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != medicationType.MedicationTypeId)
            {
                return(BadRequest());
            }

            db.Entry(medicationType).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MedicationTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void RecordIntake(MedicationType type, int amount = 1)
 {
     var intake = new MedicationIntake();
     intake.MedicationType = type;
     intake.Amount = amount;
     intake.Timestamp = DateTime.Now;
     Save(intake);
 }
Example #4
0
 //Saves data to databse through model
 public async Task<IActionResult> Create([Bind("MedicationTypeId,Name")] MedicationType medicationType)
 {
     if (ModelState.IsValid)
     {
         _context.Add(medicationType);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(medicationType);
 }
        public IHttpActionResult GetMedicationType(int id)
        {
            MedicationType medicationType = db.MedicationTypes.Find(id);

            if (medicationType == null)
            {
                return(NotFound());
            }

            return(Ok(medicationType));
        }
        public IHttpActionResult PostMedicationType(MedicationType medicationType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MedicationTypes.Add(medicationType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = medicationType.MedicationTypeId }, medicationType));
        }
        public IHttpActionResult DeleteMedicationType(int id)
        {
            MedicationType medicationType = db.MedicationTypes.Find(id);

            if (medicationType == null)
            {
                return(NotFound());
            }

            db.MedicationTypes.Remove(medicationType);
            db.SaveChanges();

            return(Ok(medicationType));
        }
Example #8
0
        void PrepareTestData()
        {
            dc1         = new DistributionCentre();
            dc1.ID      = 1;
            dc1.Name    = "Head Office";
            dc1.Address = "Bennelong Point, Sydney NSW 2000";
            dc1.Phone   = "92507111";

            dc2         = new DistributionCentre();
            dc2.ID      = 2;
            dc2.Name    = "Liverpool Office";
            dc2.Address = "Macquarie Street, Liverpool NSW 2170";
            dc2.Phone   = "96026633";

            agent          = new Employee();
            agent.Username = "******";
            agent.Fullname = "Innkeeper";
            agent.Email    = "*****@*****.**";
            agent.EmployeeRole.Add(new EmployeeRole {
                Id = "1", Name = Role.Agent.ToString()
            });
            agent.DistributionCentreId = dc1.ID;

            doctor          = new Employee();
            doctor.Username = "******";
            doctor.Fullname = "Jim Raynor";
            doctor.Email    = "*****@*****.**";
            doctor.EmployeeRole.Add(new EmployeeRole {
                Id = "2", Name = Role.Doctor.ToString()
            });
            doctor.DistributionCentreId = dc2.ID;

            type1             = new MedicationType();
            type1.ID          = 1;
            type1.Name        = "100 polio vaccinations";
            type1.ShelfLife   = 365;
            type1.Value       = 500;
            type1.IsSensitive = true;

            type2             = new MedicationType();
            type2.ID          = 2;
            type2.Name        = "box of 500 x 28 pack chloroquine pills";
            type2.ShelfLife   = 7300;
            type2.Value       = 3000;
            type2.IsSensitive = true;
        }