private async void AddSaveOwnerCommandExecuted() { try { if (string.IsNullOrWhiteSpace(Name)) { SnackError("Ingrese un nombre", "Error", Helpers.TypeSnackBar.Top); return; } if (string.IsNullOrWhiteSpace(Address)) { SnackError("Ingrese una direccion", "Error", Helpers.TypeSnackBar.Top); return; } if (string.IsNullOrWhiteSpace(User)) { SnackError("Ingrese un usuario", "Error", Helpers.TypeSnackBar.Top); return; } if (string.IsNullOrWhiteSpace(Phone)) { SnackError("Ingrese un telefono", "Error", Helpers.TypeSnackBar.Top); return; } var admin = DbContext.Instance.GetAdministrator(); var o = new OwnerModel(); o.Password = Encrypt.Crypt(User); o.IdAdmin = admin.IdAdmin; o.Address = Address; o.Name = Name; o.IconString = string.Empty; o.Phone = Phone; o.User = Encrypt.Crypt(User); o.Icon = null; var response = await client.Post <ListResponse, OwnerModel>(o, $"administrator/insowner"); if (response != null) { if (response.Result && response.Count > 0) { await PopupNavigation.Instance.PopAllAsync(true); MessagingCenter.Send <AddOwnerPopupPageViewModel>(this, "home"); SnackSucces("Se agrego correctamente", "KyA", TypeSnackBar.Top); } else { SnackError(response.Message, "Error", TypeSnackBar.Top); } } else { SnackError("Hubo un error intentelo mas tarde", "Error", TypeSnackBar.Top); } } catch (Exception ex) { } }
private async void LoginCommandExecuted() { if(!string.IsNullOrWhiteSpace(User)) { if(!string.IsNullOrWhiteSpace(Password)) { if (SelectedTypeUser != null) { var device = DbContext.Instance.GetDeviceToken(); var auth = new AuthenticateModel(); auth.User = Encrypt.Crypt(User); auth.Password = Encrypt.Crypt(Password); auth.PlayerId = device.PlayerId; auth.PushToken = device.PushToken; if (SelectedTypeUser.Id == 0) { //Usuario Show("Cargando"); var response = await client.Post<Models.User.User, AuthenticateModel>(auth, "user/seluser"); if (response != null) { if (response.Result != null && response.Count > 0) { Hide(); //entra al masterdetailpage del usuario DbContext.Instance.InsertUser(response.Result); MainPage(new Views.User.MasterDetailUser()); } else { Hide(); SnackError(response.Message, "Error", TypeSnackBar.Top); } } else { Hide(); SnackError("Hubo un error con el servidor intentelo mas tarde", "Error", TypeSnackBar.Top); } } else if (SelectedTypeUser.Id == 1) { //propietario Show("Cargando"); var response = await client.Post<Models.Owner.Owner, AuthenticateModel>(auth, "owner/selowner"); if (response != null) { if (response.Result != null && response.Count > 0) { Hide(); //entra al masterdetailpage DbContext.Instance.InsertOwner(response.Result); MainPage(new Views.Owner.MasterDetailOwner()); } else { Hide(); SnackError(response.Message, "Error", TypeSnackBar.Top); } } else { Hide(); SnackError("Hubo un error con el servidor intentelo mas tarde", "Error", TypeSnackBar.Top); } } else { //Administrador Show("Cargando"); var response = await client.Post<ListAdministratorModel, AuthenticateModel>(auth, "administrator/seladministrator"); if(response != null) { if(response.Result != null && response.Count > 0) { Hide(); //entra al masterdetailpage DbContext.Instance.InsertAdministrator(response.Result); MainPage(new Views.Administrator.MasterDetailAdministrator()); } else { Hide(); SnackError(response.Message, "Error", TypeSnackBar.Top); } } else { Hide(); SnackError("Hubo un error con el servidor intentelo mas tarde", "Error", TypeSnackBar.Top); } } } else { SnackError("Debe seleccionar un tipo de usuario", "Error", TypeSnackBar.Top); } } else { SnackError("Debe ingresar una contraseña", "Error", TypeSnackBar.Top); } } else { SnackError("Debe ingresar un usuario", "Error", TypeSnackBar.Top); } }
public void Crypt() { Debug.WriteLine(Encrypt.Crypt(@"HKCU\Software\Microsoft\Internet Explorer,Default_Page_URL,,", @"THOU SHALT NOT STEAL")); }
private async void UpdateUserCommandExecuted() { //accion para actualiza r el usuario try { if (!string.IsNullOrWhiteSpace(User.Password)) { if (!string.IsNullOrWhiteSpace(User.Name)) { if (ImageConvert != null) { if (!ImageConvert.Contains("http://rentapp.carlosdiaz.com.elpumavp.arvixevps.com/Image")) { User.Icon = Convert.FromBase64String(ImageConvert); } } User.Status = true; User.User = Encrypt.Crypt(User.User); User.Password = Encrypt.Crypt(User.Password); Show("Actualizando datos.."); var response = await client.Put <ListResponse, UserModel>(User, "user/updateuser"); Hide(); if (response != null) { if (response.Result && response.Count > 0) { SnackSucces("Datos actualizados", "KYA", Helpers.TypeSnackBar.Top); var device = DbContext.Instance.GetDeviceToken(); var auth = new AuthenticateModel(); auth.User = User.User; auth.Password = User.Password; auth.PlayerId = device.PlayerId; auth.PushToken = device.PushToken; var responseUSer = await client.Post <Models.User.User, AuthenticateModel>(auth, "user/seluser"); if (responseUSer != null) { if (responseUSer.Result != null && responseUSer.Count > 0) { DbContext.Instance.InsertUser(responseUSer.Result); LoadImage(); MessagingCenter.Send <App>((App)Xamarin.Forms.Application.Current, "user"); } } // } } else { SnackError("Hubo un error intentelo mas tarde", "Error", Helpers.TypeSnackBar.Top); } } else { SnackError("Ingrese un nombre", "Error", Helpers.TypeSnackBar.Top); } } else { SnackError("Ingrese una contraseña", "Error", Helpers.TypeSnackBar.Top); } } catch (Exception ex) { Hide(); } }