async Task ExecuteLoadVaccineCommand() { if (IsBusy) { return; } IsBusy = true; try { Vaccines.Clear(); var vaccineTmp = await CurrentDataStore.CurrentDALC.GetVaccineDBProvider.GetAllVaccines(); foreach (var vacinaItem in vaccineTmp) { Vaccines.Add(vacinaItem); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
[Route("{Key}")] //<--key == petId public ActionResult PutEdit(int key, [FromBody] Vaccines vac) { pethouseContext db = new pethouseContext(); try { Vaccines vacDb = db.Vaccines.Find(key); if (vac != null) { vacDb.Vacname = vac.Vacname; vacDb.VacDate = vac.VacDate; vacDb.VacExpDate = vac.VacExpDate; db.SaveChanges(); return(Ok(vacDb.VacId)); } else { return(NotFound("Not found")); } } catch (Exception) { return(BadRequest("Error")); } finally { db.Dispose(); } }
public ActionResult DeleteConfirmed(int id) { Vaccines vaccines = db.Vaccines.Find(id); db.Vaccines.Remove(vaccines); db.SaveChanges(); return(RedirectToAction("Index")); }
public MedicalRecord UpdateVaccines(Vaccines vaccine, MedicalRecord medicalRecord) { MedicalRecord medicalRecordToUpdate = medicalRecordRepository.GetObject(medicalRecord.IdRecord); if (!medicalRecordToUpdate.Vaccines.Any(entity => entity.Name.Equals(vaccine.Name))) { medicalRecordToUpdate.Vaccines.Add(vaccine); } return(medicalRecordRepository.Update(medicalRecordToUpdate)); }
public ActionResult Edit([Bind(Include = "VaccineId,VaccineCode,Name")] Vaccines vaccines) { if (ModelState.IsValid) { db.Entry(vaccines).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vaccines)); }
public ActionResult Create([Bind(Include = "VaccineId,VaccineCode,Name")] Vaccines vaccines) { if (ModelState.IsValid) { db.Vaccines.Add(vaccines); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vaccines)); }
public Vaccine GetVaccine(int vid) { List <Vaccine> vaccs = new Vaccines(sql).Get(true); foreach (Vaccine v in vaccs) { if (v.ID == vid) { return(v); } } return(null); }
public Vaccines Create(Vaccines entity) { if (!ExistsInSystem(entity)) { List <Vaccines> allVaccines = (List <Vaccines>)stream.GetAll(); allVaccines.Add(entity); stream.SaveAll(allVaccines); return(entity); } else { throw new EntityAlreadyExists(ALREADY_EXISTS); } }
protected override void OnQueryChanged(string oldValue, string newValue) { base.OnQueryChanged(oldValue, newValue); if (string.IsNullOrWhiteSpace(newValue)) { ItemsSource = null; } else { ItemsSource = Vaccines .Where(session => session.Name.ToLower().Contains(newValue.ToLower())) .ToList(); } }
public ActionResult <bool> CreateItem([FromBody] Vaccines entity) { try { var c = new vaccineContext(); c.Vaccines.Add(entity); c.SaveChanges(); return(true); } catch (System.Exception) { return(BadRequest()); } }
// GET: Vaccines/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vaccines vaccines = db.Vaccines.Find(id); if (vaccines == null) { return(HttpNotFound()); } return(View(vaccines)); }
// GET: Admin/Vaccine/Edit/5 public ActionResult Edit(int?id) { if (Session["isLogin"] != null && (bool)Session["isLogin"] == true) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vaccines vaccines = db.Vaccines.Find(id); if (vaccines == null) { return(HttpNotFound()); } return(View(vaccines)); } return(RedirectToAction("Index", "Login")); }
[HttpPost] //<-- filtteri, joka sallii vain POST-metodit //[Route("")]// <-- Routen placeholder public ActionResult PostCreateNew([FromBody] Vaccines vac) { pethouseContext db = new pethouseContext(); //Tietokanta yhteytden muodostus try { db.Vaccines.Add(vac); db.SaveChanges(); } catch (Exception ex) { string virhe = ex.GetType().Name.ToString() + ": " + ex.Message.ToString(); return(BadRequest("Jokin meni pieleen asiakasta lisättäessä.\nOta yhteyttä Guruun!\n" + virhe)); } db.Dispose(); //Tietokannan vapautus return(Ok(vac.PetId)); //Palauttaa vastaluodun uuden objektin avainarvon }
//Hae kaikki Rokotukset public Vaccines GetTheLatestVaccine(int key) { pethouseContext db = new pethouseContext(); Vaccines vaccines = (from p in db.Vaccines where p.PetId == key orderby p.VacDate descending select p).FirstOrDefault(); if (vaccines != null) { return(vaccines); } else { return(null); } }
public ActionResult DeleteVaccine(int?key) { if (key is null) { throw new ArgumentNullException(nameof(key)); } pethouseContext db = new pethouseContext(); try { Vaccines vaccine = db.Vaccines.Find(key); db.Remove(vaccine); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public ActionResult <bool> UpdateItem(int id, [FromBody] Vaccines entity) { try { var c = new vaccineContext(); Vaccines existing = c.Vaccines.Where(p => p.Id == id).SingleOrDefault(); //values existing.Name = entity.Name is null ? existing.Name : entity.Name; existing.Amounted = entity.Amounted is null ? existing.Amounted : entity.Amounted; c.Update(existing); c.SaveChanges(); return(true); } catch (System.Exception) { return(BadRequest()); } }
public ActionResult DeleteAllVaccines(int?key) { if (key is null) { throw new ArgumentNullException(nameof(key)); } pethouseContext db = new pethouseContext(); try { Vaccines vaccineRow = db.Vaccines.Where(s => s.PetId == key).FirstOrDefault(); db.Remove(vaccineRow); db.SaveChanges(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public bool ExistsInSystem(Vaccines vaccines) { var allVaccines = stream.GetAll().ToList(); return(allVaccines.Any(item => item.Name == vaccines.Name)); }
private void VaccineButton_Click(object sender, RoutedEventArgs e) { Vaccines vaccinesWindow = new Vaccines(); vaccinesWindow.Show(); }
public MedicalRecord UpdateVaccines(Vaccines vaccine, MedicalRecord medicalRecord) => medicalRecordService.UpdateVaccines(vaccine, medicalRecord);
public Vaccines CreateVaccine(Vaccines vaccine) => vaccinesRepository.Create(vaccine);
public Vaccines CreateVaccine(Vaccines vaccine) => vaccinesService.CreateVaccine(vaccine);