public static GuestInternal ToInternal(this GuestContract entity) { if (entity == null) { return(null); } var guest = new GuestInternal { Name = entity.Name, Surname = entity.Surname, PersonalCode = entity.PersonalCode }; return(guest); }
public static VisitInternal ToInternal(this VisitContract entity) { if (entity == null) { return(null); } ResidentInternal visitResident = new ResidentInternal(); GuardInternal visitGuard = new GuardInternal(); DormitoryInternal visitDormitory = new DormitoryInternal(); GuestInternal visitGuest = new GuestInternal(); using (MainDbModelContainer1 db = new MainDbModelContainer1()) { visitResident = db.ResidentSet.Find(entity.ResidentId); visitGuard = db.GuardSet.Find(entity.GuardId); visitDormitory = db.DormitorySet.Find(entity.DormitoryId); visitGuest = db.GuestSet.Find(entity.GuestId); } var visit = new VisitInternal { ID = entity.ID, VisitRegDateTime = entity.VisitRegDateTime, IsOver = entity.IsOver, VisitEndDateTime = entity.VisitEndDateTime, ResidentPersonalCode = visitResident.PersonalCode, GuardPersonalCode = visitGuard.PersonalCode, DormitoryID = visitDormitory.ID, Guest_PersonalCode = visitGuest.PersonalCode, IsConfirmed = entity.IsConfirmed, Resident = visitResident, Guard = visitGuard, Dormitory = visitDormitory, Guest = visitGuest }; return(visit); }