public ActionResult DeleteCrop(int id, CropDataViewModel cropDataViewModel) //Deletes the requested Product (identified by the Product ID) { try { Crop myCrop = _cropService.GetCrop(id); _cropService.DeleteCrop(myCrop); CropHarvest myCropHarvest = _cropService.GetCropHarvest(id); _cropService.DeleteCropHarvest(myCropHarvest); CropRequirements myCropRequirements = _cropService.GetCropRequirements(id); _cropService.DeleteCropRequirements(myCropRequirements); } catch (Exception ex) { // Might be worth looking at redirection to an error page ViewBag.Exception = ex; return(View()); } return(RedirectToAction("Crops", new { controller = "Crop" })); }
public ActionResult EditCrop(int id, CropDataViewModel cropDataViewModel, Crop crop, CropHarvest cropHarvest, CropRequirements cropRequirements) { try { Crop myCrop = new Crop { cropId = cropDataViewModel.CropId, cropName = cropDataViewModel.CropName, cropSize = cropDataViewModel.SpaceRequired }; CropHarvest myCroph = new CropHarvest { cropId = cropDataViewModel.CropId, earliestHarvest = cropDataViewModel.EarlyHarvest, latestHarvest = cropDataViewModel.LateHarvest, earliestPlant = cropDataViewModel.EarlyPlanting, latestPlant = cropDataViewModel.LatePlanting, growthTime = cropDataViewModel.growthTime }; CropRequirements myCropr = new CropRequirements { cropId = cropRequirements.cropId, birdNetting = cropRequirements.birdNetting, slugPellets = cropRequirements.slugPellets, Feed = cropRequirements.Feed, wateringInterval = cropRequirements.wateringInterval }; _cropService.editCrop(myCrop, myCroph, myCropr); return(RedirectToAction("Crops", new { controller = "Crop" })); } catch { return(View()); } }
public ActionResult AddCrop(Crop crop, CropHarvest croph, CropRequirements cropr, CropDataViewModel cropDataViewModel) { try { Crop mycrop = new Crop { cropId = cropDataViewModel.CropId, cropName = cropDataViewModel.CropName, cropSize = cropDataViewModel.SpaceRequired }; _cropService.addCrop(mycrop); CropHarvest myCroph = new CropHarvest { cropId = cropDataViewModel.CropId, earliestHarvest = cropDataViewModel.EarlyHarvest, latestHarvest = cropDataViewModel.LateHarvest, earliestPlant = cropDataViewModel.EarlyPlanting, latestPlant = cropDataViewModel.LatePlanting, growthTime = cropDataViewModel.growthTime, }; _cropService.addCropHarvest(myCroph); _cropService.addCropRequirements(cropr); return(RedirectToAction("Crops", new { controller = "Crop" })); } catch (Exception ex) { // Might be worth looking at redirection to an error page ViewBag.Exception = ex; return(View()); } }
public void editCrop(Crop crop, CropHarvest cropHarvest, CropRequirements cropRequirements) { Crop myCrop = GetCrop(crop.cropId); myCrop.cropName = crop.cropName; myCrop.cropSize = crop.cropSize; CropHarvest myCroph = GetCropHarvest(cropHarvest.cropId); myCroph.earliestHarvest = cropHarvest.earliestHarvest; myCroph.latestHarvest = cropHarvest.latestHarvest; myCroph.earliestPlant = cropHarvest.earliestPlant; myCroph.latestPlant = cropHarvest.latestPlant; myCroph.growthTime = cropHarvest.growthTime; CropRequirements myCropr = GetCropRequirements(cropRequirements.cropId); myCropr.birdNetting = cropRequirements.birdNetting; myCropr.slugPellets = cropRequirements.slugPellets; myCropr.Feed = cropRequirements.Feed; myCropr.wateringInterval = cropRequirements.wateringInterval; _context.SaveChanges(); }
public void DeleteCropRequirements(CropRequirements cropRequirements) { _cropDAO.DeleteCropRequirements(cropRequirements); }
public void editCrop(Crop crop, CropHarvest cropHarvest, CropRequirements cropRequirements) { _cropDAO.editCrop(crop, cropHarvest, cropRequirements); }
public void addCropRequirements(CropRequirements crop) { _cropDAO.addCropRequirements(crop); }
public void DeleteCropRequirements(CropRequirements cropRequirements) { _context.CropRequirements.Remove(cropRequirements); _context.SaveChanges(); }
public void addCropRequirements(CropRequirements cropRequirements) { _context.CropRequirements.Add(cropRequirements); _context.SaveChanges(); }