Example #1
0
        public Objects.activities.Place AddPlace(Objects.activities.Place item)
        {
            item.id = 0;
            var _entity = Mapper.Map <Entities.activities.Place>(item);

            _entity = _ctx.activities_places.Add(_entity);
            _ctx.SaveChanges();
            return(Mapper.Map <Objects.activities.Place>(_entity));
        }
Example #2
0
        public void DeletePlace(Objects.activities.Place item)
        {
            var _entity = _ctx.activities_places.FirstOrDefault(x => x.id == item.id);

            if (_entity == null)
            {
                throw new ArgumentException("Place not exist");
            }
            _ctx.activities_places.Remove(_entity);
            _ctx.SaveChanges();
        }
Example #3
0
        public Objects.activities.Place UpdatePlace(Objects.activities.Place item)
        {
            var _entity = _ctx.activities_places.FirstOrDefault(x => x.id == item.id);

            if (_entity == null)
            {
                throw new ArgumentException("Place not exist");
            }

            var __entity = Mapper.Map(item, _entity);

            _ctx.Entry(__entity).State = System.Data.Entity.EntityState.Modified;
            _ctx.SaveChanges();
            return(Mapper.Map <Objects.activities.Place>(__entity));
        }
Example #4
0
        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()));
        }