Example #1
0
 private static void UpdateUserProfile(UpdateProfileCommand command, User user)
 {
     user.Profile = new Profile
     {
         FirstName      = command.FirstName,
         LastName       = command.LastName,
         CellPhone      = command.CellPhone,
         CreationDate   = DateTime.Now,
         LastUpdateDate = DateTime.Now,
         Avatar         = new ProfileAvatar
         {
             Name           = command.Picture.Name,
             Address        = command.Picture.Address,
             CreationDate   = DateTime.Now,
             LastUpdateDate = DateTime.Now
         }
     };
 }
Example #2
0
        public ICommandResult Execute(UpdateProfileCommand command)
        {
            try
            {
                if (command == null)
                {
                    throw new ArgumentNullException();
                }

                var user = _membershipRepository.GetById(command.UserId);
                UpdateUserProfile(command, user);
                _membershipRepository.Edit(user);
                _unitOfWork.Commit();
                return(new SuccessResult(MembershipCommandMessage.UserEditedSuccessfully));
            }
            catch (MembershipCommandException exception)
            {
                _logger.Error(exception.Message);
                return(new FailureResult(MembershipCommandMessage.UserEditionFailed));
            }
        }