Exemple #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);
        }
Exemple #2
0
        public static ResidentContract ToContract(this ResidentInternal entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var resi = new ResidentContract
            {
                Name         = entity.Name,
                PersonalCode = entity.PersonalCode,
                Surname      = entity.Surname,
                DormitoryId  = entity.Dormitory.ID,
                RoomId       = entity.Room.ID,
                Username     = entity.Username,
                Password     = entity.Password
            };

            return(resi);
        }
Exemple #3
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);
        }