public IActionResult UpdateUser(ProfileCommands model) { try { ProfileCommand profile = new ProfileCommand() { Email = model.Email, FullName = model.FullName, About = model.About, ImageProfile = model.ImageProfile, ImageProfilePath = model.ImageProfilePath }; bool isSuccess = _authService.UpdateProfile(profile); if (isSuccess) { SuccessModel.SuccessCode = "200"; SuccessModel.SuccessMessage = "Update Completed."; return(Ok(SuccessModel)); } else { ErrorModel.ErrorCode = "400"; ErrorModel.ErrorMessage = "Not found"; return(BadRequest(ErrorModel)); } } catch (Exception ex) { ErrorModel.ErrorMessage = ex.Message; ErrorModel.ErrorCode = "500"; return(StatusCode(500, ErrorModel)); } }
public async Task <Result <SuccessModel, ErrorModel> > Update(ProfileCommands model) { Uri url = new Uri(BaseUriUser, $"/Auth/Update"); Result <SuccessModel, ErrorModel> result = await PostMethodAsync <SuccessModel, ErrorModel>(url, model); return(result); }
/// <summary> /// Chargement de l'utilisateur /// </summary> public async void GetAppUser() { // On créé un dummy profile si on est en mode design if (_isInDesignMode) { _appUser = new User(); } else { //On charge depuis la mémoire locale l'utilisateur try { var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; string userNickname = (string)roamingSettings.Values["user_nickname"]; _appUser = await User.LoadUserFromTemporaryStorage(userNickname); } catch { //L'utilisateur n'existe pas dans la mémoire locale, on se déconnecte Resources.APIWebTeam.Connection.Disconnect(); } } RaisePropertyChanged("Username"); RaisePropertyChanged("Nickname"); RaisePropertyChanged("Promo"); RaisePropertyChanged("Groupe"); RaisePropertyChanged("DateDeNaissance"); //Mise en place des champs de commande //Commande pour appeler if (!_appUser.numeroPortable.Equals("")) { Action command; //Si on peut appeler if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsPhoneContract", 1, 0)) { command = new Action(() => { PhoneCallManager.ShowPhoneCallUI(_appUser.numeroPortable, Username); }); } //Si le device ne peut passer d'appel else { command = new Action(async() => { string errMsg = "Désolé, les appels ne sont pas disponnibles sur votre appareil"; MessageDialog dialog = new MessageDialog(errMsg); await dialog.ShowAsync(); }); } ProfileCommands.Add(new ProfileCommand("Appeler", _appUser.numeroPortable, command)); } //Commande pour naviguer vers if (!_appUser.adresse.Equals("")) { Action command = new Action(async() => { var locFinderResult = await MapLocationFinder.FindLocationsAsync(_appUser.adresse, new Geopoint(new BasicGeoposition())); if (locFinderResult.Locations[0] == null) { string errMsg = "Désolé, impossible de trouver où " + _appUser.prenom + " habite"; MessageDialog dialog = new MessageDialog(errMsg); await dialog.ShowAsync(); return; } var geoPos = locFinderResult.Locations[0].Point.Position; var driveToUri = new Uri(String.Format( "ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}", geoPos.Latitude, geoPos.Longitude, _appUser.prenom + " " + _appUser.nom)); await Windows.System.Launcher.LaunchUriAsync(driveToUri); }); ProfileCommands.Add(new ProfileCommand("Obtenir un itinéraire", _appUser.adresse, command)); } //Si on est en mode design, on ne charge pas l'image (plantage de la visu) if (!_isInDesignMode) { //Récupération de l'avatar profilePicture = await _appUser.GetAvatar(); RaisePropertyChanged("ProfilePicture"); } IsLoaded = true; }