예제 #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 RoomContract ToContract(this RoomInternal entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var room = new RoomContract
            {
                ID          = entity.ID,
                Number      = entity.Number,
                DormitoryId = entity.Dormitory.ID
            };

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