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; }
//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); }
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(); }
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); }
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); } }
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); }