public void DeletePlantFromPlantGroup(string gardenName, string plantGroupName, string plantName, string accountID) { if (string.IsNullOrEmpty(gardenName)) { throw new ArgumentException("message", nameof(gardenName)); } if (string.IsNullOrEmpty(plantGroupName)) { throw new ArgumentException("message", nameof(plantGroupName)); } if (string.IsNullOrEmpty(plantName)) { throw new ArgumentException("message", nameof(plantName)); } Garden garden = GardenRepository.GetByName(gardenName, accountID); PlantGroup plantGroup = PlantGroupRepository.GetByName(plantGroupName, accountID); Plant plant = PlantRepository.GetByName(plantName); //Not sure this is needed? plantGroup.DeletePlant(plant); PlantGroupRepository.DeletePlantFromPlantGroup(plantGroup, plant, accountID); }
public ActionResult <(string, string)> GetIncompatibilities(string plantGroupName, string plantName, string accountID) { var plantGroup = PlantGroupRepository.GetByName(plantGroupName, accountID); if (plantGroup == null) { return(NotFound()); } var plant = PlantRepository.GetByName(plantName); if (plant == null) { return(NotFound()); } List <(Plant, List <IPlantRequirement>)> requirementList = plantGroup.GetAllIncompatibilities(plant); List <(string, string)> expandedList = new List <(string, string)>(); foreach ((Plant, List <IPlantRequirement>)reqPair in requirementList) { foreach (IPlantRequirement req in reqPair.Item2) { expandedList.Add((reqPair.Item1.Name, req.TypeOfReq())); } } return(Ok(expandedList)); }
public void AddPlantToPlantGroup(string gardenName, string plantGroupName, string plantName, string accountID) { if (string.IsNullOrEmpty(gardenName)) { throw new ArgumentException("message", nameof(gardenName)); } if (string.IsNullOrEmpty(plantGroupName)) { throw new ArgumentException("message", nameof(plantGroupName)); } if (string.IsNullOrEmpty(plantName)) { throw new ArgumentException("message", nameof(plantName)); } Garden garden = GardenRepository.GetByName(gardenName, accountID); PlantGroup plantGroup = PlantGroupRepository.GetByName(plantGroupName, accountID); Plant plant = PlantRepository.GetByName(plantName); plantGroup.AddPlant(plant); PlantGroupRepository.AddPlantToPlantGroup(plantGroup, plant, accountID); //should be update }
public ActionResult <PlantGroup> GetPlantGroupByName(string name, string accountID) { var plantGroup = PlantGroupRepository.GetByName(name, accountID); if (plantGroup != null) { return(plantGroup); } return(NotFound()); }
public void DeletePlantGroup(string gardenName, string plantGroupName, string accountID) { if (string.IsNullOrEmpty(gardenName)) { throw new ArgumentException("message", nameof(gardenName)); } if (plantGroupName == null) { throw new ArgumentNullException(nameof(plantGroupName)); } Garden garden = GardenRepository.GetByName(gardenName, accountID); PlantGroup plantGroup = PlantGroupRepository.GetByName(plantGroupName, accountID); PlantGroupRepository.DeletePlantGroup(garden, plantGroup, accountID); }