private async void ImageCommandExecuted() { var statusStorage = await Utils.PermissionsStatus(Plugin.Permissions.Abstractions.Permission.Storage); var statuscamera = await Utils.PermissionsStatus(Plugin.Permissions.Abstractions.Permission.Camera); if (statuscamera && statusStorage) { byte[] Image = null; string action = await App.Current.MainPage.DisplayActionSheet("", "Cancelar", null, "Galeria", "Camara"); if (action == "Galeria") { Image = await PhotoCamera.PickPhoto(); } else if (action == "Camara") { Image = await PhotoCamera.TakePhoto(); } if (Image != null) { var admin = DbContext.Instance.GetAdministrator(); var message = new MessageOwnerToAdmin(); message.IdAdmin = admin.IdAdmin; message.IdOwner = Owner.IdOwner; message.Image = Image; message.Message = string.Empty; message.StringImage = string.Empty; message.TypeMessage = 1; message.TypeSendUser = 1; var response = await client.Post <ListResponse, MessageOwnerToAdmin>(message, "messageownertoadmin/insmessageownertoadmin"); if (response != null) { if (response.Result && response.Count > 0) { Message = string.Empty; LoadMessage(); } } } } else { SnackError("habilita los permisos", "Error", TypeSnackBar.Top); } }
private async void ImageCommandExecuted() { try { var status = await Utils.PermissionsStatus(Plugin.Permissions.Abstractions.Permission.Camera); if (status) { string action = await App.Current.MainPage.DisplayActionSheet("", "Cancelar", null, "Galeria", "Camara"); if (action == "Camara") { var img = await PhotoCamera.TakePhoto(); ImageConvert = Convert.ToBase64String(img); } else if (action == "Galeria") { var img = await PhotoCamera.PickPhoto(); ImageConvert = Convert.ToBase64String(img); } else { ImageConvert = null; } } else { SnackError("Habilite los permisos de uso de la camara", "Error", Helpers.TypeSnackBar.Top); } } catch (Exception ex) { } }