Example #1
0
        public void Update(Entities.Vacancy value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <Vacancy>().SingleOrDefault(s => s.ID == value.ID);

                existed.Title            = value.Title;
                existed.ShortDescription = value.ShortDescription;
                existed.Bonuses          = value.Bonuses;
                existed.Requirments      = value.Requirments;
                existed.Responsibilities = value.Responsibilities;
                existed.WeOffer          = value.WeOffer;
                existed.CreatedDate      = value.CreatedDate;
                existed.IsPositionOpen   = value.IsPositionOpen;

                existed.Technologies = HandleCollection <Technology, int>(
                    existed.Technologies.ToList(),
                    value.Technologies.ToList(),
                    tech => tech.ID,
                    dbContext);

                scope.SaveChanges();
            }
        }
Example #2
0
        public void Delete(Entities.Vacancy value)
        {
            using (var scope = _dbContextScopeFactory.Create())
            {
                var dbContext = scope.DbContexts
                                .Get <ApplicationDbContext>();

                var existed = dbContext.Set <Vacancy>().SingleOrDefault(s => s.ID == value.ID);

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

                scope.SaveChanges();
            }
        }