Ejemplo n.º 1
0
        public void Insert(ServiceSubcategory value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                dbContext.Set <ServiceSubcategory>().Add(value);

                scope.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void Delete(ServiceSubcategory value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <ServiceSubcategory>().SingleOrDefault(c => c.ID == value.ID);

                dbContext.Set <ServiceSubcategory>().Remove(existed);

                scope.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void Update(ServiceSubcategory value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <ServiceSubcategory>().SingleOrDefault(c => c.ID == value.ID);

                existed.Name = value.Name;
                existed.ServiceCategoryID = value.ServiceCategoryID;

                scope.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        private static List <ServiceSubcategory> CreateServiceSubcategories(int numberServiceSubcategories)
        {
            List <ServiceSubcategory> serviceSubcategories = new List <ServiceSubcategory>();

            for (int n = 1; n <= numberServiceSubcategories; n++)
            {
                ServiceSubcategory serviceSubcategory = new ServiceSubcategory
                {
                    ServiceSubcategoryId = n,
                    Name = $"Service Subcategory { n}"
                };

                serviceSubcategories.Add(serviceSubcategory);
            }

            return(serviceSubcategories);
        }