Пример #1
0
        public static ResidentInternal ToInternal(this ResidentContract entity)
        {
            if (entity == null)
            {
                return(null);
            }
            DormitoryInternal resiDormitory = new DormitoryInternal();
            RoomInternal      resiRoom      = new RoomInternal();

            using (MainDbModelContainer1 db = new MainDbModelContainer1())
            {
                resiDormitory = db.DormitorySet.Find(entity.DormitoryId);
                resiRoom      = db.RoomSet.Find(entity.RoomId);
            }

            var resi = new ResidentInternal
            {
                Name         = entity.Name,
                PersonalCode = entity.PersonalCode,
                Surname      = entity.Surname,
                Dormitory    = resiDormitory,
                Room         = resiRoom,
                Username     = entity.Username,
                Password     = entity.Password
            };

            return(resi);
        }
Пример #2
0
        public static GuardInternal ToInternal(this GuardContract entity)
        {
            if (entity == null)
            {
                return(null);
            }
            DormitoryInternal guardDormitory = new DormitoryInternal();

            using (MainDbModelContainer1 db = new MainDbModelContainer1())
            {
                guardDormitory = db.DormitorySet.Find(entity.DormitoryId);
            }

            var guard = new GuardInternal
            {
                Name         = entity.Name,
                PersonalCode = entity.PersonalCode,
                Surname      = entity.Surname,
                Dormitory    = guardDormitory,
                Username     = entity.Username,
                Password     = entity.Password
            };

            return(guard);
        }
Пример #3
0
        public static DormitoryInternal ToInternal(this DormitoryContract entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dorm = new DormitoryInternal
            {
                ID     = entity.ID,
                Adress = entity.Adress,
                Name   = entity.Name
            };

            return(dorm);
        }
Пример #4
0
        public static AdministratorInternal ToInternal(this AdministratorContract entity)
        {
            if (entity == null)
            {
                return(null);
            }

            MainDbModelContainer1 db             = new MainDbModelContainer1();
            DormitoryInternal     adminDormitory = db.DormitorySet.Find(entity.DormitoryId);

            var admin = new AdministratorInternal
            {
                Name         = entity.Name,
                PersonalCode = entity.PersonalCode,
                Surname      = entity.Surname,
                Dormitory    = adminDormitory
            };

            return(admin);
        }
Пример #5
0
        public static RoomInternal ToInternal(this RoomContract entity)
        {
            if (entity == null)
            {
                return(null);
            }
            DormitoryInternal roomDormitory = new DormitoryInternal();

            using (MainDbModelContainer1 db = new MainDbModelContainer1())
            {
                roomDormitory = db.DormitorySet.Find(entity.DormitoryId);
            }

            var room = new RoomInternal
            {
                ID        = entity.ID,
                Number    = entity.Number,
                Dormitory = roomDormitory
            };

            return(room);
        }
Пример #6
0
        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);
        }