Beispiel #1
0
        public void Handle(ChangeProfileSettingsRequest changeProfileSettingsRequest)
        {
            int     currentUserId = _userAccessor.GetCurrentUserId();
            AppUser appUser       = _bodyFitTrackerContext.AppUsers.Where(x => x.AppUserId == currentUserId).First();

            appUser.Email = changeProfileSettingsRequest.Email;
            // all units must be in imperial in the database
            appUser.Height = MeasurementConverter.ConvertLength(changeProfileSettingsRequest.Height, changeProfileSettingsRequest.UnitsOfMeasure, MeasurementSystem.Imperial);
            appUser.MeasurementSystemPreference = changeProfileSettingsRequest.UnitsOfMeasure;

            _bodyFitTrackerContext.SaveChanges();
        }
        public void UserProfileShouldBeUpdatedBasedOffRequest()
        {
            ChangeProfileSettingsRequest request = new ChangeProfileSettingsRequest
            {
                Email          = "*****@*****.**",
                Height         = 70,
                UnitsOfMeasure = MeasurementSystem.Imperial
            };

            _changeProfileSettingsHandler.Handle(request);

            BodyFitTrackerContext bodyFitTrackerContext = DatabaseConnectionFactory.GetInMemoryDatabase(false);
            AppUser appUser = bodyFitTrackerContext.AppUsers.Where(x => x.AppUserId == _userId).First();

            Assert.AreEqual("*****@*****.**", appUser.Email);
            Assert.AreEqual(70, appUser.Height);
        }
Beispiel #3
0
 public void ChangeProfileSettings(ChangeProfileSettingsRequest changeProfileSettingsRequest)
 {
     _changeProfileSettingsHandler.Handle(changeProfileSettingsRequest);
 }