Beispiel #1
0
        public void UpdateUserProfile(UpdateProfileInputModel model)
        {
            var userProfile = _subscriberRepository.GetById(model.Id);

            userProfile.EmailAddress = model.EmailAddress;
            userProfile.ModifiedBy   = Environment.UserName;
            userProfile.ModifiedDate = DateTime.Now;

            var userBodyMass = new BodyMass
            {
                Profile_Fk     = userProfile.Profile_Pk,
                HeightInInches = model.Height,
                WeightInPounds = model.Weight,
                CreateDate     = DateTime.Now,
                CreatedBy      = Environment.UserName,
                StartDate      = DateTime.Now
            };

            var bmis = _subscriberBodyMassRepository.GetAll().Any(x => x.WeightInPounds == model.Weight &&
                                                                  x.HeightInInches == model.Height &&
                                                                  x.CreateDate.Date == DateTime.Today);

            if (userProfile.EmailAddress == model.EmailAddress && bmis)
            {
                return;
            }

            _subscriberRepository.Update(userProfile);
            _subscriberBodyMassRepository.Insert(userBodyMass);
        }
        public ActionResult UpdateProfile(SubscriberProfileViewModel model)
        {
            UpdateProfileInputModel inputModel = new UpdateProfileInputModel
            {
                Id           = 2,
                Weight       = model.Weight,
                Height       = model.Height,
                EmailAddress = model.EmailAddress,
                DateOfBirth  = model.DateOfBirth.HasValue ? model.DateOfBirth.Value : DateTime.MinValue
            };

            _subscriberProfileService.UpdateUserProfile(inputModel);

            TempData["Saved"] = $"Profile Saved @ {DateTime.Now.ToLongTimeString()}";

            return(Redirect(Request.UrlReferrer.ToString()));
        }
        private async Task LoadAsync(ApplicationUser user)
        {
            var userName = await this.userManager.GetUserNameAsync(user);

            var email = await this.userManager.GetEmailAsync(user);

            var phoneNumber = await this.userManager.GetPhoneNumberAsync(user);

            this.Username = userName;
            this.Email    = email;

            this.Input = new UpdateProfileInputModel
            {
                PhoneNumber = phoneNumber,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Address     = user.Address,
                Gender      = user.Gender.ToString(),
            };
        }
        public void UpdateUserProfile(UpdateProfileInputModel model)
        {
            var userProfile = _subscriberRepository.GetById(model.Id);

            userProfile.EmailAddress = model.EmailAddress;
            userProfile.ModifiedBy   = Environment.UserName;
            userProfile.ModifiedDate = DateTime.Now;
            userProfile.DateOfBirth  = model.DateOfBirth;

            var userBodyMass = new BodyMass
            {
                Profile_Fk     = userProfile.Profile_Pk,
                HeightInInches = model.Height,
                WeightInPounds = model.Weight,
                CreateDate     = DateTime.Now,
                CreatedBy      = Environment.UserName,
                StartDate      = DateTime.Now
            };

            _subscriberRepository.Update(userProfile);
            _subscriberBodyMassRepository.Insert(userBodyMass);
        }
        public HttpStatusCode CreateUserProfile([FromBody] UpdateProfileInputModel model)
        {
            _subscriberProfileService.UpdateUserProfile(model);

            return(HttpStatusCode.Created);
        }