예제 #1
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);
        }
예제 #2
0
        public static GuardContract ToContract(this GuardInternal entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var guard = new GuardContract
            {
                Name         = entity.Name,
                PersonalCode = entity.PersonalCode,
                Surname      = entity.Surname,
                DormitoryId  = entity.Dormitory.ID,
                Username     = entity.Username,
                Password     = entity.Password
            };

            return(guard);
        }
예제 #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);
        }