/*获取用户资料:将不为空的ID请求转发至DL,并将反馈结果翻译为数据契约*/ public UserInfo GetUserInfo(string userID) { UserInfoEntity userInfoEntity = null; if (userID == null) { userInfoEntity = new UserInfoEntity(); userInfoEntity.ErrorMessage = "314 Empty UserID! @Service"; } else { userInfoEntity = doctorLogic.GetUserInfo(userID); } UserInfo userInfo = new UserInfo(); TranslateUserInfoEntityToUserInfoContractData(userInfoEntity, userInfo); return userInfo; }
/*将UserInfo对应的Entity翻译为数据契约*/ private void TranslateUserInfoEntityToUserInfoContractData( UserInfoEntity userInfoEntity, UserInfo userInfo) { userInfo.ErrorMessage = userInfoEntity.ErrorMessage; userInfo.UserID = userInfoEntity.UserID; userInfo.LastName = userInfoEntity.LastName; userInfo.FirstName = userInfoEntity.FirstName; userInfo.Nationality = userInfoEntity.Nationality; userInfo.Gender = userInfoEntity.Gender; userInfo.ABO = userInfoEntity.ABO; userInfo.Rh = userInfoEntity.Rh; userInfo.Birthplace = userInfoEntity.Birthplace; userInfo.Birthday = userInfoEntity.Birthday; userInfo.Deathplace = userInfoEntity.Deathplace; userInfo.Deathday = userInfoEntity.Deathday; userInfo.Balance = userInfoEntity.Balance; userInfo.LastLoginDate = userInfoEntity.LastLoginDate; userInfo.City = userInfoEntity.City; userInfo.Address = userInfoEntity.Address; userInfo.Phone = userInfoEntity.Phone; userInfo.Email = userInfoEntity.Email; userInfo.EmergencyContactPerson = userInfoEntity.EmergencyContactPerson; }
/*用户登录:若ID和Password均不为空,则转发至DL,将结果翻译为数据契约*/ public UserInfo Login(string userID, string password) { UserInfoEntity userInfoEntity = null; if (userID == null) { userInfoEntity = new UserInfoEntity(); userInfoEntity.ErrorMessage = "401 Empty UserID! @Service"; } else if (password == null) { userInfoEntity = new UserInfoEntity(); userInfoEntity.ErrorMessage = "402 Empty password! @Service"; } else { userInfoEntity = userLogic.Login(userID, password); } UserInfo userInfo = new UserInfo(); TranslateUserInfoEntityToUserInfoContractData(userInfoEntity, userInfo); return userInfo; }