public void logCropAsPlanted(Planted planted) { Planted myPlanted = getPlantedCrop(planted.plantedId); myPlanted.dateIn = planted.dateIn; _context.SaveChanges(); }
public void logCropAsHarvested(Planted planted) { Planted myPlanted = getPlantedCrop(planted.plantedId); myPlanted.dateOut = planted.dateOut; _context.SaveChanges(); }
public ActionResult RemovePlantedCrop(int plantedId, Planted planted) { Planted myPlanted = _gardenService.getPlantedCrop(plantedId); _gardenService.deletePlantedCrop(myPlanted); return(RedirectToAction("ListSelectedCrops", new { controller = "Garden" })); }
public ActionResult DeleteConfirmed(int id) { Planted planted = db.Planteds.Find(id); db.Planteds.Remove(planted); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult HarvestCrop(int PlantedId, Planted planted) { Planted myPlanted = new Planted { plantedId = planted.plantedId, dateOut = DateTime.Now }; _gardenService.logCropAsHarvested(myPlanted); return(RedirectToAction("GetUserGarden", new { controller = "Garden" })); }
public ActionResult Edit([Bind(Include = "PlantedID,Status,FieldID,FieldName,CropID,CropName,QuantityPlanted,PlantedDate,ExpectedHarvestDate,ExpectedYield,LastWatered,NextWater")] Planted planted) { if (ModelState.IsValid) { db.Entry(planted).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CropID = new SelectList(db.CropInfoes, "CropID", "Name", planted.CropID); ViewBag.FieldID = new SelectList(db.Fields, "FieldID", "FieldName", planted.FieldID); return(View(planted)); }
// GET: Planteds/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Planted planted = db.Planteds.Find(id); if (planted == null) { return(HttpNotFound()); } return(View(planted)); }
// GET: Planteds/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Planted planted = db.Planteds.Find(id); if (planted == null) { return(HttpNotFound()); } ViewBag.CropID = new SelectList(db.CropInfoes, "CropID", "Name", planted.CropID); ViewBag.FieldID = new SelectList(db.Fields, "FieldID", "FieldName", planted.FieldID); return(View(planted)); }
public ActionResult ConfirmCropsToGarden(Planted planted) { var userId = User.Identity.GetUserId(); var userGarden = _gardenService.GetGardenFromUser(userId); try { // Create a new object containing planted information Planted setPlanted = new Planted { gardenId = userGarden.gardenId, cropId = planted.cropId }; // Pass it to the method _gardenService.addcropstogarden(setPlanted); Planted lastPlanted = _gardenService.GetLastPlanted(); var tends = _tendService.getTends(); foreach (var tend in tends) { Tended myTended = new Tended { cropId = planted.cropId, tendId = tend.tendId, Date = DateTime.Now.AddDays(-40), plantedId = lastPlanted.plantedId }; _tendService.setAsTended(myTended); } return(RedirectToAction("ListSelectedCrops", new { controller = "Garden" })); } catch (Exception ex) { // Might be worth looking at redirection to an error page ViewBag.Exception = ex; return(View()); } }
public void deletePlantedCrop(Planted planted) { _context.Planted.Remove(planted); _context.SaveChanges(); }
public void removecropsfromgarden(Planted planted) { _context.Planted.Remove(planted); _context.SaveChanges(); }
// Adds a crop to a garden public void addcropstogarden(Planted planted) { _context.Planted.Add(planted); _context.SaveChanges(); }
public void deletePlantedCrop(Planted planted) { _gardenDAO.deletePlantedCrop(planted); }
public void logCropAsHarvested(Planted planted) { _gardenDAO.logCropAsHarvested(planted); }
public void addcropstogarden(Planted planted) { _gardenDAO.addcropstogarden(planted); }
public virtual void ItemPlanted() { Planted?.Invoke(this); }