Esempio n. 1
0
        private async void update_Clicked(object sender, EventArgs e)
        {
            var model = new UpdateProfile()
            {
                name       = name.Text,
                email      = email.Text,
                phone      = phone.Text,
                pictureUrl = UploadedUrl.Text,
                id         = Preferences.Get("userId", string.Empty),
                tenantID   = App.AppKey
            };
            var result = await ApiServices.UpdateUserInfo(model);

            if (result)
            {
                Preferences.Set("token", string.Empty);
                Preferences.Set("userId", string.Empty);
                Preferences.Set("userName", string.Empty);
                MessageDialog.Show("Success", "Your Profile Updated Successfully", "Ok");
                await Shell.Current.GoToAsync("../..");
            }
            else
            {
                MessageDialog.Show("Oops !!!", "Error occured while updating your profile", "Ok");
            }
        }
Esempio n. 2
0
        public IHttpActionResult UpdateProfile(UpdateProfile request)
        {
            try
            {
                bool autorization = false;
                if (Request.Headers.Authorization != null)
                {
                    string Jwt = Request.Headers.Authorization.Parameter;
                    autorization = new BJwt().ConsultarJwt(Jwt);
                }

                if (!autorization)
                {
                    Resultado res = new Resultado()
                    {
                        Mensaje = "Token Invalido", Respuesta = 0
                    };
                    return(Ok(res));
                }
                Resultado resultado = new Resultado();
                resultado = BProfile.UpdateProfile(request);
                return(Ok(resultado));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }
        }
Esempio n. 3
0
        public async Task <Account> UpdateProfile(string authorization, UpdateProfile newProfile)
        {
            var authorizationString = getTokenFromAuthorization(authorization);
            var tokenContent        = readTokenAuthenticate(authorizationString);

            var userID  = tokenContent.userId;
            var account = context.Account.Include(user => user.Profile).SingleOrDefault(account => account.Id == userID);

            var currentProfile = account.Profile;

            if (newProfile != null)
            {
                account.Phonenumber      = newProfile.Phonenumber;
                account.Profile.Fullname = newProfile.Fullname;
                account.Profile.Email    = newProfile.Email;
            }

            if (newProfile.Avatar != null)
            {
                account.Profile.Avatar = SaveImage(newProfile.Avatar);
            }

            await context.SaveChangesAsync();

            return(account);
        }
        public ActionResult AddAdministrator(int?id)
        {
            var         Emailid     = User.Identity.Name.ToString();
            User        user1       = dbobj.Users.Where(x => x.EmailId == Emailid).FirstOrDefault();
            User        user        = dbobj.Users.Find(id);
            UserProfile userProfile = dbobj.UserProfiles.Where(x => x.UserId == user.ID).FirstOrDefault();

            if (user != null)
            {
                ViewBag.countrycode = dbobj.Countries.Where(x => x.isActive == true);
                UpdateProfile update = new UpdateProfile
                {
                    FirstName              = user.FirstName,
                    LastName               = user.LastName,
                    EmailId                = user.EmailId,
                    PhoneNumber            = userProfile.PhoneNumber,
                    Phonenumbercountrycode = userProfile.Phonenumbercountrycode,
                };
                return(View(update));
            }
            else
            {
                return(View());
            }
            return(View());
        }
Esempio n. 5
0
        public void InvokeMethods(UpdateProfile profile)
        {
            // get methods with specific attribute only
            var updateMethods =
                this.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                .Where(m => m.GetCustomAttributes(typeof(UpdateMethodAttribute), false).Length > 0)
                .SelectMany(m => m.GetCustomAttributes(typeof(UpdateMethodAttribute), false)
                            .Cast <UpdateMethodAttribute>()
                            .Select(uma => new
            {
                MethodInfo    = m,
                AttributeInfo = uma
            }));

            // filter down to required and special methods only
            var methodAttributes = updateMethods
                                   .Where(um => (um.AttributeInfo.Profiles != null &&
                                                 um.AttributeInfo.Profiles.Length > 0 &&
                                                 um.AttributeInfo.Profiles.Contains(profile)))
                                   .OrderBy(um => um.AttributeInfo.Sequence);

            // execute
            foreach (var methodAttribute in methodAttributes)
            {
                try
                {
                    methodAttribute.MethodInfo.Invoke(this, null);
                }
                catch (Exception e)
                {
                    Console.WriteLine(methodAttribute.MethodInfo.Name + " failed to execute.");
                    Console.WriteLine(e.Message);
                }
            }
        }
Esempio n. 6
0
        public async Task <ApiResult <bool> > UserUpdateProfile(Guid userId, UpdateProfile request)
        {
            var user = await _userManager.FindByIdAsync(userId.ToString());

            if (user == null)
            {
                return(new ApiResultErrors <bool>($"Can not find user with id: {userId}"));
            }

            user.FullName    = request.FullName;
            user.PhoneNumber = request.Phone;
            user.Address     = request.Address;
            user.Dob         = request.Dob;

            //Save Image
            if (request.ThumbnailImage != null)
            {
                var OldImagePath = user.ImagePath;
                user.ImagePath = await this.SaveFile(request.ThumbnailImage);

                if (OldImagePath != null)
                {
                    await _storageService.DeleteFileAsync(OldImagePath);
                }
            }

            var result = await _userManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                return(new ApiResultSuccess <bool>());
            }
            return(new ApiResultErrors <bool>("update failed"));
        }
Esempio n. 7
0
        public async Task <ApiResult <string> > Update(Guid userId, UpdateProfile request)
        {
            MultipartFormDataContent form = new MultipartFormDataContent();

            form.Add(new StringContent(request.FullName), "FullName");
            form.Add(new StringContent(request.Phone), "Phone");
            form.Add(new StringContent(request.Address), "Address");
            form.Add(new StringContent(request.Dob.ToString()), "Dob");
            if (request.ThumbnailImage != null)
            {
                byte[] data;
                using (var br = new BinaryReader(request.ThumbnailImage.OpenReadStream()))
                    data = br.ReadBytes((int)request.ThumbnailImage.OpenReadStream().Length);
                ByteArrayContent bytes = new ByteArrayContent(data);
                form.Add(bytes, "ThumbnailImage", request.ThumbnailImage.FileName);
            }

            var response = await _client.PatchAsync($"/api/users/userUpdate/{userId}", form);

            var result = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ApiResultSuccess <string> >(result));
            }
            return(JsonConvert.DeserializeObject <ApiResultErrors <string> >(result));
        }
Esempio n. 8
0
        public async Task <IActionResult> UpdateProfile(
            [FromForm] UpdateProfile command)
        {
            command.Principal = User;

            var result = await _mediator.Send(command);

            return(Ok(result));
        }
Esempio n. 9
0
        public async Task Given_A_Non_Existing_UserId__When_Calling_Update_Profile_Usecase__Throws_Profile_Not_Found_Exception()
        {
            // Arrange
            var request = new UpdateProfile(this.userId, "Bio", "Image", "DisplayName");
            var handler = new UpdateProfileHandler(this.unitOfWork);

            // Act + Assert
            Assert.That(async() => await handler.Handle(request, CancellationToken.None), Throws.InstanceOf <ProfileNotFoundException>());
        }
        public void UpdateProfile(UpdateProfile entity)
        {
            Profiles profileToUpdate = this._DbContext.Profiles.Find(entity.ProfileId);

            profileToUpdate.Name        = entity.Name;
            profileToUpdate.Description = entity.Description;
            profileToUpdate.State       = entity.State;
            this._DbContext.SaveChanges();
        }
Esempio n. 11
0
        public async Task <ActionResult> UpdateProfileAsync(UpdateProfile updateProfile)
        {
            Result result = await profileService.UpdateAsync(User.Id(), updateProfile.ToDto());

            if (result.Status)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Esempio n. 12
0
 public void UpdateProfile(UpdateProfile entity)
 {
     try
     {
         _unitOfWork.ProfilesRepository.UpdateProfile(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 13
0
        public void ThenHeIsNavigatedToHisProfileSectionToUpdateAndEventuallyLogsOut()
        {
            //Skill seeker updates his/her profile
            UpdateProfile updateprofile = new UpdateProfile();

            updateprofile.AddDescription(driver);
            updateprofile.AddLanguage(driver);
            updateprofile.AddSkills(driver);
            updateprofile.AddEducation(driver);
            updateprofile.Signout(driver);
        }
Esempio n. 14
0
        public ProfileViewModel()
        {
            _themeColor = (Color)Application.Current.Resources["MainColor"];

            GetMyUserInfo();

            var CService = MvvmNanoIoC.Resolve <CredentialService>();

            PasswordWasSaved = CService.DoCredentialsExist();

            var master = (MasterDetailPage)Application.Current.MainPage;

            _EditSwitch = new ToolbarItem
            {
                Text = "\uf044"
            };

            _logout = new ToolbarItem
            {
                Text = "\uf08b"
            };

            _logout.Clicked += (sender, e) =>
            {
                ((ToolbarItem)sender).IsEnabled = false;
                RemovePass();
            };


            _EditSwitch.Clicked += async(sender, e) =>
            {
                if (!EditMode)
                {
                    _EditSwitch.Text = "\uf00c";
                }
                else
                {
                    _EditSwitch.Text = "\uf044";
                    NotifyPropertyChanged("UserInfo");
                    var updateUser = new UpdateProfile();
                    updateUser.firstName     = _userInfo.firstName;
                    updateUser.lastName      = _userInfo.lastName;
                    updateUser.gender        = _userInfo.gender;
                    updateUser.note          = _userInfo.description;
                    updateUser.email         = _userInfo.email != OldUserData.email ? _userInfo.email : null;
                    updateUser.maxGraduation = _userInfo.maxGraduation;
                    await MvvmNanoIoC.Resolve <TutorScoutRestService>().UpdateUser(updateUser);
                }
                EditMode = !EditMode;
                ViewMode = !EditMode;
            };

            AddToolBarItem();
        }
Esempio n. 15
0
        public bool EditProfile(UpdateProfile request, int id)
        {
            User user = userRepository.FindById(id);

            user.Nume    = request.Nume;
            user.Prenume = request.Prenume;
            user.Parola  = request.Parola;

            userRepository.Update(user);
            return(userRepository.SaveChanges());
        }
        public ActionResult Profile(UpdateProfile model)
        {
            var user = _userManager.FindById(model.Id);

            user.Name     = model.Name;
            user.Surname  = model.Surname;
            user.UserName = model.Username;
            user.Email    = model.Email;
            _userManager.Update(user);
            return(View("Update"));
        }
Esempio n. 17
0
        public IActionResult Put([FromBody] UpdateProfile profile)
        {
            var authorization = AuthorizationString();

            if (authorization == null)
            {
                return(Unauthorized());
            }
            var updateResult = profileService.UpdateProfile(authorization, profile).Result;

            return(Ok(updateResult));
        }
        public ActionResult AddAdministrator(UpdateProfile updateProfile, int?id)
        {
            var  Emailid = User.Identity.Name.ToString();
            User user1   = dbobj.Users.Where(x => x.EmailId == Emailid).FirstOrDefault();

            ViewBag.countrycode = dbobj.Countries.Where(x => x.isActive == true);
            if (ModelState.IsValid)
            {
                UserProfile userProfile1 = dbobj.UserProfiles.Where(x => x.UserId == id).FirstOrDefault();
                if (userProfile1 != null)
                {
                    userProfile1.User.FirstName         = updateProfile.FirstName;
                    userProfile1.User.LastName          = updateProfile.LastName;
                    userProfile1.PhoneNumber            = updateProfile.PhoneNumber;
                    userProfile1.Phonenumbercountrycode = updateProfile.Phonenumbercountrycode;
                    userProfile1.User.ModifiedBy        = user1.ID;
                    userProfile1.User.ModifiedDate      = DateTime.Now;
                    userProfile1.ModifiedDate           = DateTime.Now;
                    userProfile1.ModifiedBy             = user1.ID;
                    dbobj.Entry(userProfile1).State     = EntityState.Modified;
                    dbobj.SaveChanges();
                }
                else
                {
                    User user = new User
                    {
                        RoleID      = 2,
                        FirstName   = updateProfile.FirstName,
                        LastName    = updateProfile.LastName,
                        EmailId     = updateProfile.EmailId,
                        IsActive    = true,
                        CreatedDate = DateTime.Now,
                        CreatedBy   = user1.ID,
                        Password    = Crypto.Hash("admin123"),
                    };
                    dbobj.Users.Add(user);
                    dbobj.SaveChanges();
                    UserProfile userProfile = new UserProfile
                    {
                        UserId                 = user.ID,
                        PhoneNumber            = updateProfile.PhoneNumber,
                        Phonenumbercountrycode = updateProfile.Phonenumbercountrycode,
                        IsActive               = true,
                        CreatedDate            = DateTime.Now,
                        CreatedBy              = user1.ID,
                    };
                    dbobj.UserProfiles.Add(userProfile);
                    dbobj.SaveChanges();
                    SendVerificationLinkEmail(updateProfile.EmailId.ToString());
                }
            }
            return(RedirectToAction("ManageAdministrator", "ManageSystem"));
        }
        public async Task <IActionResult> UserUpdate([FromRoute] Guid userId, [FromForm] UpdateProfile request)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            var result = await _userService.UserUpdateProfile(userId, request);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Esempio n. 20
0
        public async Task <WorkerAccount> UpdateAccount(int userID, UpdateProfile profile)
        {
            var currentAccount = GetByID(userID);

            if (profile.Phonenumber != null)
            {
                currentAccount.Phonenumber = profile.Phonenumber;
            }
            currentAccount.WorkerProfile.Email    = profile.Email;
            currentAccount.WorkerProfile.Fullname = profile.Fullname;
            await context.SaveChangesAsync();

            return(currentAccount);
        }
Esempio n. 21
0
        public void UpdateProfile(UpdateProfile profile)
        {
            using (var connection = GetConnection())
            {
                if (UserSecretsConfigurationExtensions.)
                {
                    connection.Execute("Update Student Set email_address = @emailAddress, mobile_number = @mobileNo where student_id = @Id", new { Id = SessionVar.GetInt("SID"), emailAddress = profile.Email, mobileNo = profile.Mobile });
                }

                if (User.lecturer)
                {
                    connection.Execute("Update Lecturer Set email_address = @emailAddress, contact_number = @mobileNo where lecturer_id = @Id", new { Id = SessionVar.GetInt("LID"), emailAddress = profile.Email, mobileNo = profile.Mobile });
                }
            }
        }
Esempio n. 22
0
        public async Task <IActionResult> UpdateProfile([FromRoute] int id, [FromBody] UpdateProfile usuario)
        {
            if (usuario.Id != id)
            {
                return(StatusCode(StatusCodes.Status409Conflict,
                                  $"Id do usuario divergente do id informado"));
            }
            var usuarioLogado = _servicoInformacaoUsuario.Ra;



            var user = await _repositoryUserManage.UpdateProfile(usuario);

            return(Ok(user));
        }
        public ActionResult Profile()
        {
            var id   = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();
            var user = _userManager.FindById(id);
            var data = new UpdateProfile()
            {
                Id       = user.Id,
                Name     = user.Name,
                Surname  = user.Surname,
                Email    = user.Email,
                Username = user.UserName
            };

            return(View(data));
        }
Esempio n. 24
0
        public async Task <ApplicationResponse> When(UpdateProfile command)
        {
            var customer = await _customerRepository.Get(command.Id);

            if (customer == null)
            {
                return(ApplicationResponse.Fail(StatusCode.NotFound, "Customer not found"));
            }

            customer.UpdateProfile(command.Email, command.Firstname, command.Lastname);

            await _customerRepository.Update(customer);

            return(ApplicationResponse.Success());
        }
Esempio n. 25
0
        public async Task <IActionResult> Update(Guid customerId, [FromBody] UpdateProfile updateProfile)
        {
            if (!updateProfile.IsValid() && customerId == Guid.Empty)
            {
                return(BadRequest("User input not valid"));
            }

            var result = await _customerService.Update(customerId, updateProfile.ToDomain(customerId));

            if (result.StatusCode == ECommerce.Shared.StatusCode.NotFound)
            {
                return(NotFound("customer reference not found"));
            }

            return(Ok());
        }
Esempio n. 26
0
        //update person info
        public static async Task <bool> UpdateUserInfo(UpdateProfile req)
        {
            TokenValidator.CheckTokenValidity();
            var client  = new HttpClient();
            var json    = JsonConvert.SerializeObject(req);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Preferences.Get("token", string.Empty));
            var response = await client.PutAsync(updateuserUrl, content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
        public async Task <Usuario> UpdateProfile(UpdateProfile user)
        {
            var id = Convert.ToInt32(_informacaoUsuario.IdUsuario);

            var _user = GetById(id);

            _user.Nome           = user.Name;
            _user.Ra             = user.Ra;
            _user.Sobrenome      = user.LastName;
            _user.Email          = user.Email;
            _user.NumeroTelefone = user.NumeroTelefone;


            _user = Update(_user);

            return(await Task.FromResult(_user));
        }
Esempio n. 28
0
        public async Task Given_An_Existing_Profile__When_Calling_UpdateProfile_Usecase__Returns_Updated_Profile()
        {
            // Arrange
            var profile = await this.CreateTestProfile();

            var request = new UpdateProfile(this.userId, "Bio", "Image", "DisplayName");
            var handler = new UpdateProfileHandler(this.unitOfWork);

            // Act
            var updatedProfile = await handler.Handle(request, CancellationToken.None);

            // Assert
            Assert.AreEqual(profile.Username, updatedProfile.Username);
            Assert.AreEqual(request.Bio, updatedProfile.Bio);
            Assert.AreEqual(request.ImageUrl, updatedProfile.ImageUrl);
            Assert.AreEqual(request.DisplayName, updatedProfile.DisplayName);
        }
        public async Task <IActionResult> UpdateInfo([FromForm] UpdateProfile request)
        {
            if (ModelState.IsValid)
            {
                var UserId = new Guid(ViewBag.UserId);
                var result = await _userAPIClient.Update(UserId, request);

                if (result.IsSuccessed)
                {
                    return(RedirectToAction("Profile", "user"));
                }
                return(View(ModelState.ErrorCount));
            }
            else
            {
                return(View(ModelState.ErrorCount));
            }
        }
Esempio n. 30
0
        public async Task UpdateProfile(UpdateProfile updates)
        {
            Account _account = new();

            if (Context.Items.ContainsKey("account"))
            {
                Account account = (Account)Context.Items["account"];
                _account = _unitOfWork.Account.GetById(account.Id.ToString());
            }
            else
            {
                return;
            }

            _account.Biography      = updates.Biography;
            _account.ProfilePicture = updates.Avatar;

            _unitOfWork.SaveChanges();
        }