public void CreateSubject(Subject subject) { using (var context = new SchedulesEntities1()) { Subject newSubject = new Subject { Name = subject.Name, Ects = subject.Ects, Description = subject.Description, Durations = subject.Durations }; Schedule newSchedule = subject.Schedules.First(); Professor newProfessor = subject.Professors.First(); Hall newHall = subject.Halls.First(); context.Schedules.Attach(newSchedule); context.Professors.Attach(newProfessor); context.Halls.Attach(newHall); newSubject.Schedules.Add(newSchedule); newSubject.Professors.Add(newProfessor); newSubject.Halls.Add(newHall); context.Subjects.Add(newSubject); context.SaveChanges(); } }
public void UpdateSubject(Subject subject) { using (var context = new SchedulesEntities1()) { context.Subjects.Attach(subject); context.Entry(subject).State = EntityState.Modified; context.SaveChanges(); context.Entry(subject).State = EntityState.Detached; } }
public void DeleteSchedule(Schedule selectedSchedule) { using (var context = new SchedulesEntities1()) { var deletedSchedule = context.Schedules.SingleOrDefault(x => x.Id == selectedSchedule.Id); if (deletedSchedule != null) { context.Schedules.Remove(deletedSchedule); } context.SaveChanges(); } }
public void DeleteProfile(User user) { using (var context = new SchedulesEntities1()) { var deletedUser = context.Users.SingleOrDefault(x => x.Id == user.Id); if (deletedUser != null) { context.Users.Remove(deletedUser); } context.SaveChanges(); } }
public void DeleteHall(Hall hall) { using (var context = new SchedulesEntities1()) { var deletedHall = context.Halls.SingleOrDefault(x => x.Id == hall.Id); if (deletedHall != null) { context.Halls.Remove(deletedHall); } context.SaveChanges(); } }
public void CreateHall(Hall hall) { using (var context = new SchedulesEntities1()) { Hall newHall = new Hall { Name = hall.Name, Seats = hall.Seats }; context.Halls.Add(newHall); context.SaveChanges(); } }
public void DeleteProfessor(Professor professor) { using (var context = new SchedulesEntities1()) { var deletedProfessor = context.Professors.SingleOrDefault(x => x.Id == professor.Id); if (deletedProfessor != null) { context.Professors.Remove(deletedProfessor); } context.SaveChanges(); } }
public void DeleteSubject(Subject subject) { using (var context = new SchedulesEntities1()) { var deletedSubject = context.Subjects.SingleOrDefault(x => x.Id == subject.Id); if (deletedSubject != null) { context.Subjects.Remove(deletedSubject); } context.SaveChanges(); } }
public void CreateSchedule(User user, string name) { using (var context = new SchedulesEntities1()) { Schedule newSchedule = new Schedule { Name = name, IdUser = user.Id }; context.Schedules.Add(newSchedule); context.SaveChanges(); } }
public void CreateProfile(User user) { using (var context = new SchedulesEntities1()) { User newUser = new User { Username = user.Username, Password = user.Password, Email = user.Email }; context.Users.Add(newUser); context.SaveChanges(); } }
public void UpdateHall(Hall hall) { using (var context = new SchedulesEntities1()) { var updatedHall = context.Halls.SingleOrDefault(x => x.Id == hall.Id); if (updatedHall != null) { updatedHall.Name = hall.Name; updatedHall.Seats = hall.Seats; } context.SaveChanges(); } }
public void CreateProfessor(Professor professor) { using (var context = new SchedulesEntities1()) { Professor newProfessor = new Professor { Name = professor.Name, Surname = professor.Surname, Email = professor.Email }; context.Professors.Add(newProfessor); context.SaveChanges(); } }
public void UpdateProfile(User user) { using (var context = new SchedulesEntities1()) { var updatedUser = context.Users.SingleOrDefault(x => x.Id == user.Id); if (updatedUser != null) { updatedUser.Username = user.Username; updatedUser.Password = user.Password; updatedUser.Email = user.Email; } context.SaveChanges(); } }
public void UpdateProfessor(Professor professor) { using (var context = new SchedulesEntities1()) { var updatedProfessor = context.Professors.SingleOrDefault(x => x.Id == professor.Id); if (updatedProfessor != null) { updatedProfessor.Name = professor.Name; updatedProfessor.Surname = professor.Surname; updatedProfessor.Email = professor.Email; } context.SaveChanges(); } }