public UserProfileEntity ToDataEntity(UserModel model, UserProfileEntity userProfile) { var starSign = new StarSignHandler().GetByName(StarsignCalculator.GetStarsignName(model.Birthday)); if (!starSign.CompletedRequest) { return(null); } return(new UserProfileEntity { UserProfileId = userProfile.UserProfileId, UserAge = AgeCalculator.GetDifferenceInYears(model.Birthday, DateTime.Now), UserProfileBirthday = model.Birthday, UserProfileName = model.Name, UserProfileSurname = model.Surname, UserProfileDescription = model.Description, UserProfileJob = model.Job, UserProfilePhone = model.Phone, GenderId = model.GenderId, OrientationId = model.OrientationId, StatusId = model.StatusId, ReligionId = model.ReligionId, UserId = userProfile.UserId, Motto = model.Motto, StarsignId = starSign.Entity.SignId }); }
private void PopulateModel(UserModel userModel, UserEntity user, UserProfileEntity userProfile) { userModel.Religions = SelectListGenerator.GetSelectedReligions(userProfile); userModel.Statuses = SelectListGenerator.GetSelectedStatuses(userProfile); userModel.Orientations = SelectListGenerator.GetSelectedOrientations(userProfile); userModel.Genders = SelectListGenerator.GetSelectedGenders(userProfile); userModel.Email = user.UserEmail; userModel.UserName = user.UserUsername; userModel.Description = string.IsNullOrWhiteSpace(userProfile.UserProfileDescription) ? "" : userProfile.UserProfileDescription; userModel.Phone = string.IsNullOrWhiteSpace(userProfile.UserProfilePhone) ? "" : userProfile.UserProfilePhone; userModel.Job = string.IsNullOrWhiteSpace(userProfile.UserProfileJob) ? "" : userProfile.UserProfileJob; userModel.Name = userProfile.UserProfileName; userModel.Surname = userProfile.UserProfileSurname; userModel.ReligionId = userProfile.ReligionId; userModel.StatusId = userProfile.StatusId; userModel.OrientationId = userProfile.OrientationId; userModel.GenderId = userProfile.GenderId; userModel.Age = AgeCalculator.GetDifferenceInYears(userProfile.UserProfileBirthday, DateTime.Now); userModel.Birthday = userProfile.UserProfileBirthday; userModel.BirthdayString = DateFormatter.GetDate(userProfile.UserProfileBirthday); userModel.Starsign = StarsignCalculator.GetStarsignName(userProfile.UserProfileBirthday); userModel.Motto = string.IsNullOrWhiteSpace(userProfile.Motto) ? "" : userProfile.Motto; var prefHandler = new PreferenceHandler(); userModel.LikesList = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, true).Entity.ToList(); userModel.DislikesList = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, false).Entity.ToList(); }
private UserProfileEntity ToDataEntity(RegisterModel model, int userId) { var starSignName = StarsignCalculator.GetStarsignName(model.UserProfileBirthday); var starSignResponse = new StarSignHandler().GetByName(starSignName); if (!starSignResponse.CompletedRequest) { return(null); } return(new UserProfileEntity { UserAge = AgeCalculator.GetDifferenceInYears(model.UserProfileBirthday, DateTime.Now), UserProfileBirthday = model.UserProfileBirthday, UserProfileName = model.UserProfileName, UserProfileSurname = model.UserProfileSurname, GenderId = model.GenderId, OrientationId = model.OrientationId, StatusId = model.StatusId, ReligionId = model.ReligionId, UserId = userId, StarsignId = starSignResponse.Entity.SignId }); }