public static TeacherDTO GetTeacherDetailsByTeacherId(int id) { using (Gymnastics_Studio_DataEntities GSDE = new Gymnastics_Studio_DataEntities()) { Teacher1 teacher = new Teacher1(); teacher = GSDE.Teacher1.FirstOrDefault(x => x.Id == id); return(TeacherDTO.ConvertToDTO(teacher)); } }
public static Teacher1 ConvertFromDTO(TeacherDTO teacherDTO) { Teacher1 teacher = new Teacher1(); teacher.Id = teacherDTO.Id; teacher.LastName = teacherDTO.LastName; teacher.FirstName = teacherDTO.FirstName; teacher.IdentityNumber = teacherDTO.IdentityNumber; return(teacher); }
public static TeacherDTO ConvertToDTO(Teacher1 teacher) { TeacherDTO teacherDTO = new TeacherDTO(); teacherDTO.Id = teacher.Id; teacherDTO.LastName = teacher.LastName; teacherDTO.FirstName = teacher.FirstName; teacherDTO.IdentityNumber = teacher.IdentityNumber; teacherDTO.PhoneNumber = teacher.PhoneNumber; return(teacherDTO); }
public static List <string> GetTeacherNameList(List <int> teacherIdList) { using (Gymnastics_Studio_DataEntities GSDE = new Gymnastics_Studio_DataEntities()) { List <string> teacherNameList = new List <string>(); foreach (int teacherId in teacherIdList) { Teacher1 teacher = new Teacher1(); teacher = GSDE.Teacher1.Where(x => x.Id == teacherId).FirstOrDefault(); teacherNameList.Add(teacher.FirstName + " " + teacher.LastName); } return(teacherNameList); } }
public void M2() { Person1 p1 = new Teacher1("Bill", "Wagner", "Math"); var(first, last) = p1; Console.WriteLine(first); var p2 = p1 with { FirstName = "Paul" }; var p3 = (Teacher1) p1 with { FirstName = "Paul", Subject = "Literature" }; var clone = p1 with { }; }
public static int AddTeacher(TeacherDTO teacherDTO) { try { using (Gymnastics_Studio_DataEntities context = new Gymnastics_Studio_DataEntities()) { Teacher1 teacher = new Teacher1(); teacher.FirstName = teacherDTO.FirstName?.TrimStart().TrimEnd(); teacher.LastName = teacherDTO.LastName?.TrimStart().TrimEnd(); teacher.IdentityNumber = teacherDTO.IdentityNumber?.TrimStart().TrimEnd(); teacher.PhoneNumber = teacherDTO.PhoneNumber?.TrimStart().TrimEnd(); context.Teacher1.Add(teacher); context.SaveChanges(); return(context.Teacher1.Max(o => o.Id)); } } catch (Exception e) { throw e; } }