Example #1
0
        public Species Add(string name, int genusId, bool described, string description, int minSize, int maxSize, int temperamentId, string userName)
        {
            var genus = this.dataContext.Genus.FirstOrDefault(g => g.Id == genusId);

            if (genus == null)
            {
                throw new ItemDoesNotExistException();
            }

            if (temperamentId == 0)
            {
                temperamentId = 1;
            }

            var temperament = this.dataContext.Temperaments.FirstOrDefault(t => t.Id == temperamentId);

            if(temperament == null)
            {
                throw new ItemDoesNotExistException();
            }

            var species = new Species { Described = described, Genus = genus, Name = name.Trim(), Description = description, MinSize = minSize, MaxSize = maxSize, Temperament = temperament };

            species = this.dataContext.Species.Add(species);

            this.dataContext.SaveChanges();

            return species;
        }
        public SpeciesPageViewModel Build(Species species)
        {
            var headerViewModel = this.headerViewModelFactory.BuildFromSpecies(species.Id);

            var genusPanel = this.genusPanelViewModelFactory.Build(species.Genus.GenusType.Id);

            var viewModel = new SpeciesPageViewModel { Species = DtoFactory.Build(species), Fish = this.fishRepository.GetBySpecies(species.Id).ToDtoList(), HeaderViewModel = headerViewModel, Locales = this.localesRepository.GetWithSpecies(species.Id).ToDtoList(), PhotoGalleryViewModel = this.photoGalleryViewModelFactory.Build(species), GenusPanelViewModel = genusPanel, Description = string.Format("Profile, photos and map for {0}", species.FullName), Keywords = "Lake " + species.Genus.GenusType.Lake.Name + ", " + species.Genus.Name + ", " + string.Join(", ", species.Genus.Species.Select(x => x.Name)) };

            return viewModel;
        }
Example #3
0
 public SpeciesDto Build(Species species)
 {
     return new SpeciesDto
                {
                    Id = species.Id,
                    Name = species.FullName,
                    UrlName = species.UrlName,
                    HasPhotos = species.HasPhotos
                };
 }
Example #4
0
 public Fish Build(int id, Species species, Locale locale, bool hasPhoto)
 {
     return new Fish(id)
             {
                    Genus = species.Genus,
                    Species = species,
                    Locale = locale,
                    HasPhotos = hasPhoto
             };
 }
Example #5
0
        public Species Build(Infrastructure.Data.Species dataSpecies, Genus genus, bool hasPhotos)
        {
            var hasFish = dataSpecies.Fish.Count > 0;

            var species = new Species(dataSpecies.SpeciesID)
                              {
                                  Genus = genus,
                                  Described = Convert.ToBoolean(dataSpecies.Described),
                                  Name = dataSpecies.SpeciesName.Trim(),
                                  HaveFish = hasFish,
                                  HasPhotos = hasPhotos
                              };

            return species;
        }
        public PhotoGalleryViewModel Build(Species species)
        {
            var viewModel = new PhotoGalleryViewModel { Name = species.Name, Photos = this.photosRepository.GetForSpecies(species.Id).ToDtoList() };

            return viewModel;
        }
Example #7
0
 public static SpeciesDto Build(Species species)
 {
     return new SpeciesDto { Id = species.Id, Name = species.FullName, UrlName = species.UrlName, HasPhotos = species.HasPhotos, Description = species.Description, HasDescription = species.HasDescription, Temperament = species.Temperament.Name, SizeString = species.MaxSize == 0 || species.MinSize == 0 ? "Unknown" : string.Format("{0} - {1}cm", species.MinSize, species.MaxSize), GenusName = species.Genus.Name };
 }