Exemplo n.º 1
0
 public SpotEditViewModel(int spotId, RepositoryFactory repositoryFactory)
 {
     Models.Spot spot = repositoryFactory.GetSpotRepository().GetById(spotId);
     this.Name        = spot.Name;
     this.Description = spot.Description;
     this.Address     = spot.Address;
     this.County      = spot.County;
 }
Exemplo n.º 2
0
        //public SpotCreateViewModel(RepositoryFactory repositoryFactory)
        //{
        //    this.repositoryFactory = repositoryFactory;
        //}

        public void Persist(RepositoryFactory repositoryFactory)
        {
            Models.Spot spot = new Models.Spot
            {
                Id          = this.Id,
                Name        = this.Name,
                Description = this.Description
            };
            repositoryFactory.GetSpotRepository().Save(spot);
        }
Exemplo n.º 3
0
 public SpotEditViewModel(int spotId, RepositoryFactory repositoryFactory)
 {
     Models.Spot spot = repositoryFactory.GetSpotRepository().GetById(spotId);
     this.Name        = spot.Name;
     this.Description = spot.Description;
     this.Address     = spot.Address;
     this.County      = spot.County;
     this.CategoryIds = spot.CategorySpots.Select(cs => cs.CategoryId).ToList();
     this.Categories  = repositoryFactory.GetCategoryRepository().GetModels().ToList();
 }
Exemplo n.º 4
0
 public void Update(int id, RepositoryFactory repositoryFactory)
 {
     Models.Spot spot = new Models.Spot
     {
         Id          = id,
         Name        = this.Name,
         Description = this.Description,
         Address     = this.Address,
         County      = this.County
     };
     repositoryFactory.GetSpotRepository().Update(spot);
 }
        public void Persist(RepositoryFactory repositoryFactory)
        {
            Models.Spot spot = new Models.Spot
            {
                Name        = this.Name,
                Description = this.Description,
                Address     = this.Address,
                County      = this.County
            };
            List <Models.CategorySpot> categorySpots = CreateManyToManyRelationships(spot.Id);

            spot.CategorySpots = categorySpots;
            repositoryFactory.GetSpotRepository().Save(spot);
        }
Exemplo n.º 6
0
 public SpotListItemViewModel(Models.Spot spot)
 {
     this.Id          = spot.Id;
     this.Name        = spot.Name;
     this.Description = spot.Description;
     if (spot.Ratings.Count() == 0)
     {
         this.AverageRating = 0;
     }
     else
     {
         this.AverageRating = Math.Round(spot.Ratings.Average(s => s.Rating), 2);
     }
 }
Exemplo n.º 7
0
        public void Update(int id, RepositoryFactory repositoryFactory)
        {
            Models.Spot spot = new Models.Spot
            {
                Id          = id,
                Name        = this.Name,
                Description = this.Description,
                Address     = this.Address,
                County      = this.County
            };
            List <Models.CategorySpot> categorySpots = CreateManyToManyRelationships(spot.Id, repositoryFactory);

            spot.CategorySpots = categorySpots;
            repositoryFactory.GetSpotRepository().Update(spot);
        }