public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException (string.Format(Utilities.Messages.ExceptionMessages .InexistentDecoration, decorationType)); } IAquarium aquarium = this.aquariums.FirstOrDefault(a => a.Name == aquariumName); if (aquarium == null) { throw new InvalidOperationException (Utilities.Messages.ExceptionMessages.InvalidAquariumType); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return(string.Format(Utilities.Messages .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) { IDecoration decoration = decorations.FindByType(decorationType); IAquarium aquarium = aquariums.FirstOrDefault(x => x.Name == aquariumName); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquarium.AddDecoration(decoration); decorations.Remove(decoration); 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) { IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } IAquarium aquarium = this.aquariums.Where(x => x.Name == aquariumName).FirstOrDefault(); this.decorations.Remove(decoration); aquarium.AddDecoration(decoration); return($"Successfully added {decorationType} to {aquariumName}."); }
public string InsertDecoration(string aquariumName, string decorationType) { if (this.decorationRepository.FindByType(decorationType) == null) { throw new InvalidOperationException($"There isn't a decoration of type {decorationType}."); } IAquarium aquarium = this.aquaria.First(x => x.Name == aquariumName); IDecoration decoration = this.decorationRepository.FindByType(decorationType); aquarium.AddDecoration(decoration); this.decorationRepository.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium aquarium = this.aquariums.FirstOrDefault(a => a.Key == aquariumName).Value; IDecoration decoration = this.decorations.Models.FirstOrDefault(d => d.GetType().Name == decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return(string.Format(OutputMessages.EntityAddedToAquarium, decorationType, 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) { IDecoration decor = decorations.FindByType(decorationType); if (decor == null) { throw new InvalidOperationException(string.Format(Utilities.Messages.ExceptionMessages.InexistentDecoration, decorationType)); } IAquarium aquarium = aquariums[aquariumName]; //If Error Check aquarium.AddDecoration(decor); decorations.Remove(decor); return(string.Format(Utilities.Messages.OutputMessages.EntityAddedToAquarium, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IAquarium aquarium = this.aquariums.First(x => x.Name == aquariumName); IDecoration decoration; if (this.decorRepository.FindByType(decorationType) == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } else { decoration = this.decorRepository.FindByType(decorationType); this.decorRepository.Remove(decoration); } aquarium.AddDecoration(decoration); return(string.Format(OutputMessages.DecorationAdded, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { //Posible exception IAquarium aquarium = this.aquariums.First(a => a.Name == aquariumName); IDecoration decoration = this.decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.InexistentDecoration, decorationType)); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); return(string.Format(OutputMessages.DecorationAdded, decorationType, aquariumName)); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = this.decorations.FindByType(decorationType); IAquarium aquarium = this.aquariums.First(a => a.Name == aquariumName); if (decoration == null) { string excMsg = string.Format(ExceptionMessages.InexistentDecoration, decorationType); throw new InvalidOperationException(excMsg); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); string outputMsg = string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName); return(outputMsg); }
public string InsertDecoration(string aquariumName, string decorationType) { var decoration = this.decorations.FindByType(decorationType); IAquarium aquarium = GetAquarium(aquariumName); if (decoration == null) { string exceptionMessage = string.Format(ExceptionMessages.InexistentDecoration, decorationType); throw new InvalidOperationException(exceptionMessage); } aquarium.AddDecoration(decoration); this.decorations.Remove(decoration); string result = string.Format(OutputMessages.EntityAddedToAquarium, decorationType, aquariumName); return(result); }
public string InsertDecoration(string aquariumName, string decorationType) { IDecoration decoration = decorations.FindByType(decorationType); if (decoration == null) { throw new InvalidOperationException (string.Format(ExceptionMessages .InexistentDecoration, decorationType)); } IAquarium aquarium = GetAquariumByName(aquariumName); //null aquarium.AddDecoration(decoration); decorations.Remove(decoration); return(string.Format(OutputMessages .EntityAddedToAquarium, decorationType, aquariumName)); }