Ejemplo n.º 1
0
        public Objects.users.User AddMUser(Objects.users.User item)
        {
            item.id = 0;
            var _entity = Mapper.Map <Entities.users.User>(item);

            _entity = _ctx.users.Add(_entity);
            _ctx.SaveChanges();
            return(Mapper.Map <Objects.users.User>(_entity));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public Objects.Log AddMUser(Objects.Log item)
        {
            item.id = 0;
            var _entity = Mapper.Map <Entities.Log>(item);

            _entity = _ctx.logs.Add(_entity);
            _ctx.SaveChanges();
            return(Mapper.Map <Objects.Log>(_entity));
        }
Ejemplo n.º 4
0
        public Objects.orders.Order AddOrder(Objects.orders.Order item)
        {
            item.id = 0;

            //recherche saison
            if (item.season_id == 0)
            {
                throw new ArgumentNullException("Season");
            }
            var _season = _ctx.seasons.FirstOrDefault(x => x.id == item.season_id);

            if (_season == null)
            {
                throw new ArgumentException("Season not exist");
            }

            //recherche section [facultatif]
            Entities.activities.Section _section = null;
            if (item.restriction_section_id != null)
            {
                _section = _ctx.activities_sections.FirstOrDefault(x => x.id == item.restriction_section_id);
                if (_section == null)
                {
                    throw new ArgumentException("Section not exist");
                }
            }

            //recherche section [facultatif]
            Entities.activities.Activity _activity = null;
            if (item.restriction_activity_id != null)
            {
                _activity = _ctx.activities.FirstOrDefault(x => x.id == item.restriction_activity_id);
                if (_activity == null)
                {
                    throw new ArgumentException("Activity not exist");
                }
            }

            //recherche section [facultatif]
            Entities.activities.Category _category = null;
            if (item.restriction_category_id != null)
            {
                _category = _ctx.activities_categories.FirstOrDefault(x => x.id == item.restriction_category_id);
                if (_category == null)
                {
                    throw new ArgumentException("Category not exist");
                }
            }

            //Mappage
            var _entity = Mapper.Map <Entities.orders.Order>(item);

            _entity.season   = _season; _entity.season_id = _season.id;
            _entity.section  = _section; _entity.restriction_section_id = (_section != null) ? (int?)_section.id : null;
            _entity.activity = _activity; _entity.restriction_activity_id = (_activity != null) ? (int?)_activity.id : null;
            _entity.category = _category; _entity.restriction_category_id = (_category != null) ? (int?)_category.id : null;

            //bdd
            _entity = _ctx.orders.Add(_entity);
            _ctx.SaveChanges();
            return(Mapper.Map <Objects.orders.Order>(_entity));
        }
Ejemplo n.º 5
0
        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));
        }