Exemple #1
0
        public void logCropAsPlanted(Planted planted)
        {
            Planted myPlanted = getPlantedCrop(planted.plantedId);

            myPlanted.dateIn = planted.dateIn;

            _context.SaveChanges();
        }
Exemple #2
0
        public void logCropAsHarvested(Planted planted)
        {
            Planted myPlanted = getPlantedCrop(planted.plantedId);

            myPlanted.dateOut = planted.dateOut;

            _context.SaveChanges();
        }
Exemple #3
0
        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"));
        }
Exemple #5
0
        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));
        }
Exemple #9
0
        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());
            }
        }
Exemple #10
0
 public void deletePlantedCrop(Planted planted)
 {
     _context.Planted.Remove(planted);
     _context.SaveChanges();
 }
Exemple #11
0
 public void removecropsfromgarden(Planted planted)
 {
     _context.Planted.Remove(planted);
     _context.SaveChanges();
 }
Exemple #12
0
 // 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);
 }
Exemple #16
0
 public virtual void ItemPlanted()
 {
     Planted?.Invoke(this);
 }