public string InsertDecoration(string aquariumName, string decorationType) { var decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } decorations.Remove(decoration); aquariums.FirstOrDefault(x => x.Name == aquariumName).AddDecoration(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium wantedAquarium = aquariums.FirstOrDefault(a => a.Name == aquariumName); IDecoration wantedDecoration = decorations.Models.FirstOrDefault(d => d.GetType().Name == decorationType); if (wantedDecoration == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.InexistentDecoration, decorationType)); } wantedAquarium.AddDecoration(wantedDecoration); decorations.Remove(wantedDecoration); return(String.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { aquarium = aquariums.FirstOrDefault(a => a.Name == aquariumName); decoration = decorations.Models.FirstOrDefault(a => a.GetType().Name == decorationType); if (decoration == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } aquarium.AddDecoration(decoration); decorations.Remove(decoration); return(string.Format(OutputMessages.DecorationAdded, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { if (!decorations.Models.Any(x => x.GetType().Name == decorationType)) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } IDecoration decoration = decorations.FindByType(decorationType); decorations.Remove(decoration); aquariums.FirstOrDefault(x => x.Name == aquariumName).AddDecoration(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquariums[aquariumName].AddDecoration(decoration); decorations.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorationRepository.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } IAquarium aquarium = aquariums.FirstOrDefault(p => p.Name == aquariumName); aquarium.AddDecoration(decoration); decorationRepository.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorationRepository.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } IAquarium aquarium = aquariums.FirstOrDefault(a => a.Name == aquariumName); aquarium.AddDecoration(decoration); decorationRepository.Remove(decoration); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { if (decorationType != "Ornament" && decorationType != "Plant") { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } if (decorations.FindByType(decorationType) == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } IDecoration searchedDec = decorations.FindByType(decorationType); aquariums.First(a => a.Name == aquariumName).Decorations.Add(searchedDec); decorations.Remove(searchedDec); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium currentAq = aquariums.FirstOrDefault(x => x.Name == aquariumName); IDecoration currentDecoration = decorations.FindByType(decorationType); if (currentDecoration is null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } //if (currentAq is null) //{ // throw new InvalidOperationException(ExceptionMessages.aq); //} currentAq.AddDecoration(currentDecoration); decorations.Remove(currentDecoration); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { if (decorations.FindByType(decorationType) != null) { foreach (var aquarium in aquariums) { if (aquarium.Name == aquariumName) { var decoration = decorations.FindByType(decorationType); aquarium.AddDecoration(decoration); decorations.Remove(decoration); } } } else { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } return(String.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }