public void Insert(UserBindingModel model) { using (var context = new JournalDb()) { context.Users.Add(CreateModel(model, new User())); context.SaveChanges(); } }
public void Insert(RoleBindingModel model) { using (var context = new JournalDb()) { context.Roles.Add(CreateModel(model, new Role())); context.SaveChanges(); } }
public void Insert(GroupBindingModel model) { using (var context = new JournalDb()) { context.Groups.Add(CreateModel(model, new Group())); context.SaveChanges(); } }
public void Insert(MarksBindingModel model) { using (var context = new JournalDb()) { context.Marks.Add(CreateModel(model, new Marks())); context.SaveChanges(); } }
public void Insert(DisciplineBindingModel model) { using (var context = new JournalDb()) { context.Disciplines.Add(CreateModel(model, new Discipline())); context.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }