// GET: Vettings/Edit/5 public ActionResult DogEdit(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DogVetting dogVetting = db.DogVettings.Find(id); dogVetting.TempVettingDecimal = 0; dogVetting.ReasonForVisit = String.Empty; if (dogVetting == null) { return(HttpNotFound()); } ViewBag.AnimalId = new SelectList(db.Animals.Where(e => e.AnimalTypeID == 0).Where(e => e.Adopted == false), "id", "Name", dogVetting.AnimalId); ViewBag.DewormerLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DewormerLocationId); ViewBag.FleaTickLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.FleaTickLocationId); ViewBag.HeartwormLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.HeartwormLocationId); ViewBag.DA2PPR1LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR1LocationId); ViewBag.DA2PPR2LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR2LocationId); ViewBag.DA2PPR3LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR3LocationId); ViewBag.BordetellaLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.BordetellaLocationId); ViewBag.MicrochipLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.MicrochipLocationId); ViewBag.RabiesLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.RabiesLocationId); ViewBag.SterilizationLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.SterilizationLocationId); ViewBag.MicrochipManufacturerId = new SelectList(db.Medications.Where(e => e.isMicrochipManufacturer).OrderBy(e => e.Name), "id", "name", dogVetting.MicrochipManufacturerId); return(View(dogVetting)); }
public ActionResult CreateDog(DogVetting dogVetting) { if (ModelState.IsValid) { if (dogVetting.TempVettingDecimal != 0) { var eE = new ExpenseEntry(); dogVetting.Animal = db.Animals.Find(dogVetting.AnimalId); eE.VetBillsDecimal = dogVetting.TempVettingDecimal; eE.VetBillsComment = dogVetting.Animal.name + " - " + dogVetting.ReasonForVisit; eE.AccountTypeID = 0; eE.EffectiveDate = (dogVetting.VetDiagnosisDate == null) ? DateTime.Today : dogVetting.VetDiagnosisDate; dogVetting.VettingTotalDecimal += dogVetting.TempVettingDecimal; dogVetting.Animal.VettingTotalDecimal = dogVetting.VettingTotalDecimal; db.ExpenseEntries.Add(eE); db.SaveChanges(); } db.DogVettings.Add(dogVetting); db.SaveChanges(); return(RedirectToAction("Index")); } //return View(dogVetting); return(RedirectToAction("DogIndex", "Vettings")); }
public ActionResult DeleteConfirmed(short id) { DogVetting dogVetting = db.DogVettings.Find(id); db.DogVettings.Remove(dogVetting); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Vettings/Details/5 public ActionResult DogDetails(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DogVetting dogVetting = db.DogVettings.Find(id); if (dogVetting == null) { return(HttpNotFound()); } return(View(dogVetting)); }
// GET: Vettings/Create public ActionResult CreateDog() { var dogVetting = new DogVetting() { TempVettingDecimal = 0 }; var viewModel = new NewDogVettingViewModel { Meds = db.Medications.Where(e => e.isForDogs).ToList(), RabiesLocations = rabiesLocations, BasicVaxLocations = locations, Animals = dogs, MicrochipManufactures = microchipManufactures, DogVetting = dogVetting }; return(View(viewModel)); }
public ActionResult DogEdit(DogVetting dogVetting) { if (ModelState.IsValid) { if (dogVetting.TempVettingDecimal != 0) { var eE = new ExpenseEntry(); dogVetting.Animal = db.Animals.Find(dogVetting.AnimalId); eE.VetBillsDecimal = dogVetting.TempVettingDecimal; eE.VetBillsComment = dogVetting.Animal.name + " - " + dogVetting.ReasonForVisit; eE.AccountTypeID = 0; eE.EffectiveDate = (dogVetting.VetDiagnosisDate == null) ? DateTime.Today : dogVetting.VetDiagnosisDate; dogVetting.VettingTotalDecimal += dogVetting.TempVettingDecimal; dogVetting.Animal.VettingTotalDecimal = dogVetting.VettingTotalDecimal; db.ExpenseEntries.Add(eE); db.SaveChanges(); } db.Entry(dogVetting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DogIndex")); } ViewBag.AnimalId = new SelectList(db.Animals.Where(e => e.AnimalTypeID == 0).Where(e => e.Adopted == false), "id", "Name", dogVetting.AnimalId); ViewBag.DewormerLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DewormerLocationId); ViewBag.FleaTickLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.FleaTickLocationId); ViewBag.HeartwormLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.HeartwormLocationId); ViewBag.DA2PPR1LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR1LocationId); ViewBag.DA2PPR2LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR2LocationId); ViewBag.DA2PPR3LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR3LocationId); ViewBag.BordetellaLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.BordetellaLocationId); ViewBag.MicrochipLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.MicrochipLocationId); ViewBag.RabiesLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.RabiesLocationId); ViewBag.SterilizationLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.SterilizationLocationId); ViewBag.MicrochipManufacturerId = new SelectList(db.Medications.Where(e => e.isMicrochipManufacturer).OrderBy(e => e.Name), "id", "name", dogVetting.MicrochipManufacturerId); return(View(dogVetting)); }