Esempio n. 1
0
        protected override async void DeleteExecute()
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureDeletePhoto, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary && _selectedItem is GalleryChatPhoto chatPhoto)
            {
                Function function;
                if (chatPhoto.MessageId == 0)
                {
                    function = new SetChatPhoto(_chat.Id, null);
                }
                else
                {
                    function = new DeleteMessages(_chat.Id, new[] { chatPhoto.MessageId }, true);
                }

                var response = await ProtoService.SendAsync(function);

                if (response is Ok)
                {
                    var index = Items.IndexOf(chatPhoto);
                    if (index < Items.Count - 1 && chatPhoto.MessageId != 0)
                    {
                        SelectedItem = Items[index > 0 ? index - 1 : index + 1];
                        Items.Remove(chatPhoto);
                        TotalItems--;
                    }
                    else
                    {
                        NavigationService.GoBack();
                    }
                }
            }
        }
 public static ValidationResult <SetChatPhoto> CreateValidation(this SetChatPhoto value) => new ValidationResult <SetChatPhoto>(value)
 .ValidateRequired(x => x.ChatId)
 .ValidateRequired(x => x.Photo);