public List <Objects.activities.CategoryTree> GetsCategoriesTree(Objects.Season season) { var query = _ctx.activities_categories.Where(x => true); query = query.Where(x => x.season_id == season.id); query = query.OrderBy(x => x.name); return(Mapper.Map <List <Objects.activities.CategoryTree> >(query.ToList())); }
public Objects.Season Add(Objects.Season item) { item.id = 0; var _entity = Mapper.Map <Entities.Season>(item); _entity = _ctx.seasons.Add(_entity); _ctx.SaveChanges(); return(Mapper.Map <Objects.Season>(_entity)); }
public void Delete(Objects.Season item) { var _entity = _ctx.seasons.FirstOrDefault(x => x.id == item.id); if (_entity == null) { throw new ArgumentException("Season not exist"); } _ctx.seasons.Remove(_entity); _ctx.SaveChanges(); }
public Objects.Season Update(Objects.Season item) { var _entity = _ctx.seasons.FirstOrDefault(x => x.id == item.id); if (_entity == null) { throw new ArgumentException("Season not exist"); } var __entity = Mapper.Map(item, _entity); _ctx.Entry(__entity).State = System.Data.Entity.EntityState.Modified; _ctx.SaveChanges(); return(Mapper.Map <Objects.Season>(__entity)); }
public List <Objects.activities.Session> GetsSessions(Objects.activities.Section section = null, Objects.activities.Place place = null, Objects.Season season = null) { var query = _ctx.activities_sessions.Where(x => true); if (section != null) { query = query.Where(x => x.section_id == section.id); } if (place != null) { query = query.Where(x => x.place_id == place.id); } if (season != null) { query = query.Where(x => x.section.activity.category.season_id == season.id); } query = query.OrderBy(x => x.day); return(Mapper.Map <List <Objects.activities.Session> >(query.ToList())); }
public Objects.activities.Category AddCategory(Objects.activities.Category item, Objects.Season season) { if (season == null) { throw new ArgumentNullException("Season"); } var _season = _ctx.seasons.FirstOrDefault(x => x.id == season.id); if (_season == null) { throw new ArgumentException("Season not exist"); } item.id = 0; var _entity = Mapper.Map <Entities.activities.Category>(item); _entity.season = _season; _entity.season_id = _season.id; _entity = _ctx.activities_categories.Add(_entity); _ctx.SaveChanges(); return(Mapper.Map <Objects.activities.Category>(_entity)); }