public void SetProperties(StudentProperties properties) { FirstName = properties.FirstName ?? FirstName; LastName = properties.LastName ?? LastName; Age = properties.Age ?? Age; if (properties.StudentCourse != null) { StudentCourses = properties.StudentCourse.Value.Select(x => new StudentCourse() { Course = x.Course }).ToList(); } }
static void Main(string[] args) { var context = new MyDbContext(@"data source=(LocalDb)\MSSQLLocalDB;initial catalog=EFTest;integrated security=True;"); using (var rep = new StudentRepository(context)) { var ser = new StudentService(rep); var proper = new StudentProperties() { //FirstName = "Oleksandr", //LastName = "Klymchuk", //Age = 31, StudentCourse = new List <StudentCourseProperties>() { new StudentCourseProperties() { Course = 5 }, //new StudentCourseProperties() { Course=2} } }; var d = ser.Get(2); ser.Update(2, proper); } }
public void Update(int studentId, StudentProperties properties) { repository.Update(studentId, properties); }
public void Add(StudentProperties properties) { repository.Add(properties); }