Ejemplo n.º 1
0
        public void Insert(params TTable[] entries)
        {
            if (entries == null)
            {
                throw new ArgumentNullException("entries");
            }

            _dbSet.AddRange(entries);
            _context.SaveChanges();

            DetachAll(entries);
        }
Ejemplo n.º 2
0
        public ActionResult Add(BindEmployeeTrainingViewModel arv)
        {
            SqlLiteContext context = new SqlLiteContext();

            for (int i = 0; i < arv.Trainings.Count(); i++)
            {
                var employeeTraining = context.EmployeeTrainings.Where(a => a.EmployeeId == arv.Trainings[i].EmployeeId && a.TrainingId == arv.Trainings[i].TrainingId).FirstOrDefault();

                if (arv.Trainings[i].Connected)
                {
                    if (employeeTraining == null)
                    {
                        var et = new EmployeeTraining();
                        et.EmployeeId = arv.Trainings[i].EmployeeId;
                        et.TrainingId = arv.Trainings[i].TrainingId;
                        var entity = context.EmployeeTrainings.Add(et);
                        entity.State = EntityState.Added;
                    }
                }
                else
                {
                    if (employeeTraining != null)
                    {
                        var entity = context.EmployeeTrainings.Remove(employeeTraining);
                        entity.State = EntityState.Deleted;
                    }
                }
            }
            context.SaveChanges();
            return(RedirectToAction("Cv", "Home", new { id = arv.Trainings[0].EmployeeId }));
        }
        private void AddEntitiesToContext(int start = 1, int count = 10)
        {
            // Add entities to context
            _context.AddRange(GetEntities(start, count));

            _context.SaveChanges();
        }
Ejemplo n.º 4
0
        public static void Update(Employee employee)
        {
            using var context = new SqlLiteContext();
            var entity = context.Employees.Update(employee);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Ejemplo n.º 5
0
        public static void UpdateCourseByEmployee(Training training)
        {
            using var context = new SqlLiteContext();
            var entity = context.Trainings.Update(training);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Ejemplo n.º 6
0
        public static void Delete(Assigment assigment)
        {
            using var context = new SqlLiteContext();
            var entity = context.Assigments.Remove(assigment);

            entity.State = EntityState.Deleted;

            context.SaveChanges();
        }
Ejemplo n.º 7
0
        public static void Update(Assigment assigment)
        {
            using var context = new SqlLiteContext();
            var entity = context.Assigments.Update(assigment);

            entity.State = EntityState.Modified;

            context.SaveChanges();
        }
Ejemplo n.º 8
0
        public static void Add(Employee employee)
        {
            using (var context = new SqlLiteContext())
            {
                var entity = context.Employees.Add(employee);
                entity.State = EntityState.Added;

                context.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        public static void Add(Training training)
        {
            using (var context = new SqlLiteContext())
            {
                var entity = context.Trainings.Add(training);
                entity.State = EntityState.Added;

                context.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public static void Add(Assigment assignment)
        {
            using (var context = new SqlLiteContext())
            {
                var entity = context.Assigments.Add(assignment);
                entity.State = EntityState.Added;

                context.SaveChanges();
            }
        }
Ejemplo n.º 11
0
 public static async Task <Idee> AddIdeeFromMessage(SocketUserMessage msg, string descriptionIdee)
 {
     using (var dbContext = new SqlLiteContext())
     {
         var newIdee = IdeeExtension.AddIdeeInDbContext(dbContext, descriptionIdee, msg.Author.Username);
         newIdee.SetIdMsgDiscord(await ShowIdeeInBoite(newIdee));
         dbContext.SaveChanges();
         return(newIdee);
     }
 }
Ejemplo n.º 12
0
        private static async Task UpdateIdees(SqlLiteContext dbContext, SocketTextChannel boiteChannel)
        {
            var             idees = _boiteAIdee.GetAllIdees(dbContext);
            List <IMessage> msgs  = await GetAllMsgs(boiteChannel);

            await AddMessagesForMissingIdee(idees, msgs);

            var gitHubService = new GitHubService();
            await gitHubService.CreateGitHubIssuesForMissingIdees(idees);

            dbContext.SaveChanges();

            foreach (var idee in idees)
            {
                var msgIdee = msgs.FirstOrDefault(msg => msg.Id == idee.IdMsgDiscord);
                idee.UpdateIdee(msgIdee);
                dbContext.SaveChanges();
                await UpdateDiscordMessage(idee, msgIdee);
            }

            dbContext.SaveChanges();
        }
 public void Insert(Cliente obj)
 {
     _context.Add(obj);
     _context.SaveChanges();
 }