示例#1
0
 public void Insert(UserBindingModel model)
 {
     using (var context = new JournalDb())
     {
         context.Users.Add(CreateModel(model, new User()));
         context.SaveChanges();
     }
 }
示例#2
0
 public void Insert(RoleBindingModel model)
 {
     using (var context = new JournalDb())
     {
         context.Roles.Add(CreateModel(model, new Role()));
         context.SaveChanges();
     }
 }
示例#3
0
 public void Insert(GroupBindingModel model)
 {
     using (var context = new JournalDb())
     {
         context.Groups.Add(CreateModel(model, new Group()));
         context.SaveChanges();
     }
 }
示例#4
0
 public void Insert(MarksBindingModel model)
 {
     using (var context = new JournalDb())
     {
         context.Marks.Add(CreateModel(model, new Marks()));
         context.SaveChanges();
     }
 }
示例#5
0
 public void Insert(DisciplineBindingModel model)
 {
     using (var context = new JournalDb())
     {
         context.Disciplines.Add(CreateModel(model, new Discipline()));
         context.SaveChanges();
     }
 }
示例#6
0
        public void Delete(RoleBindingModel model)
        {
            using (var context = new JournalDb())
            {
                var role = context.Roles.FirstOrDefault(rec => rec.Id == model.Id);

                if (role == null)
                {
                    throw new Exception("Должность не найдена");
                }

                context.Roles.Remove(role);
                context.SaveChanges();
            }
        }
示例#7
0
        public void Delete(GroupBindingModel model)
        {
            using (var context = new JournalDb())
            {
                var group = context.Groups.FirstOrDefault(rec => rec.Id == model.Id);

                if (group == null)
                {
                    throw new Exception("Группа не найдена");
                }

                context.Groups.Remove(group);
                context.SaveChanges();
            }
        }
示例#8
0
        public void Delete(UserBindingModel model)
        {
            using (var context = new JournalDb())
            {
                var user = context.Users.FirstOrDefault(rec => rec.Id == model.Id);

                if (user == null)
                {
                    throw new Exception("Пользователь не найден");
                }

                context.Users.Remove(user);
                context.SaveChanges();
            }
        }
示例#9
0
        public void Update(MarksBindingModel model)
        {
            using (var context = new JournalDb())
            {
                var mark = context.Marks.FirstOrDefault(rec => rec.Id == model.Id);

                if (mark == null)
                {
                    throw new Exception("Оценка не найдена");
                }

                CreateModel(model, mark);
                context.SaveChanges();
            }
        }
示例#10
0
        public void Delete(DisciplineBindingModel model)
        {
            using (var context = new JournalDb())
            {
                var discipline = context.Disciplines.FirstOrDefault(rec => rec.Id == model.Id);

                if (discipline == null)
                {
                    throw new Exception("Дисциплина не найдена");
                }

                context.Disciplines.Remove(discipline);
                context.SaveChanges();
            }
        }