private void AddEditCallback(ResultCode resultCode, VKRequestsDispatcher.Error error, GroupLink resultData)
        {
            Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (resultCode == ResultCode.Succeeded)
                {
                    if (this._link != null)
                    {
                        if (this._link.edit_title == 1)
                        {
                            this._link.name = this.Description;
                        }
                        else
                        {
                            this._link.desc = this.Description;
                        }
                    }
                    EventAggregator current = EventAggregator.Current;
                    CommunityLinkAddedOrEdited linkAddedOrEdited = new CommunityLinkAddedOrEdited();
                    linkAddedOrEdited.CommunityId = this._communityId;
                    int num = this._link != null ? 1 : 0;
                    linkAddedOrEdited.IsEditing = num != 0;
                    GroupLink groupLink = this._link ?? resultData;
                    linkAddedOrEdited.Link = groupLink;
                    current.Publish((object)linkAddedOrEdited);
                    Navigator.Current.GoBack();
                }
                else
                {
                    this.SetInProgress(false, "");
                    this.IsFormEnabled = true;
                    VKRequestsDispatcher.Error error1 = error;
                    switch (error1 != null ? error1.error_text : (string)null)
                    {
                    case null:
                        GenericInfoUC.ShowBasedOnResult((int)resultCode, "", error);
                        break;

                    default:
                        error.error_text += ".";
                        goto case null;
                    }
                }
            }));
        }
示例#2
0
        public static void ShowBasedOnResult(ResultCode resultCode, string successString = "", VKRequestsDispatcher.Error error = null)
        {
            Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (resultCode.IsCancelResultCode() || resultCode == ResultCode.ValidationCancelledOrFailed)
                {
                    return;
                }
                if (resultCode == ResultCode.Succeeded)
                {
                    if (string.IsNullOrWhiteSpace(successString))
                    {
                        return;
                    }
                    new GenericInfoUC().ShowAndHideLater(successString, null);
                }
                else
                {
                    int delayToHide = 0;
                    string text = CommonResources.Error;
                    switch (resultCode)
                    {
                    case ResultCode.Processing:
                        text = CommonResources.Registration_TryAgainLater;
                        break;

                    case ResultCode.ProductNotFound:
                        text = CommonResources.CannotLoadProduct;
                        delayToHide = 2000;
                        break;

                    case ResultCode.VideoNotFound:
                        text = CommonResources.CannotLoadVideo;
                        delayToHide = 2000;
                        break;

                    case ResultCode.WrongPhoneNumberFormat:
                        text = CommonResources.Registration_InvalidPhoneNumber;
                        break;

                    case ResultCode.PhoneAlreadyRegistered:
                        text = CommonResources.Registration_PhoneNumberIsBusy;
                        break;

                    case ResultCode.InvalidCode:
                        text = CommonResources.Registration_WrongCode;
                        break;

                    case ResultCode.InvalidAudioFormat:
                        text = CommonResources.InvalidAudioFormatError;
                        delayToHide = 3000;
                        break;

                    case ResultCode.AudioIsExcludedByRightholder:
                        text = CommonResources.AudioIsExcludedByRightholderError;
                        delayToHide = 3000;
                        break;

                    case ResultCode.MaximumLimitReached:
                        text = CommonResources.AudioFileSizeLimitReachedError;
                        delayToHide = 3000;
                        break;

                    case ResultCode.UploadingFailed:
                        text = CommonResources.FailedToConnectError;
                        delayToHide = 3000;
                        break;

                    case ResultCode.CommunicationFailed:
                        text = CommonResources.Error_Connection;
                        delayToHide = 3000;
                        break;
                    }
                    VKRequestsDispatcher.Error error1 = error;
                    string str = error1 != null ? error1.error_text :  null;
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        text = str;
                    }
                    new GenericInfoUC(delayToHide).ShowAndHideLater(text, null);
                }
            }));
        }
示例#3
0
 public static void ShowBasedOnResult(int resultCode, string successString = "", VKRequestsDispatcher.Error error = null)
 {
     GenericInfoUC.ShowBasedOnResult((ResultCode)resultCode, successString, error);
 }
        public void SaveChanges()
        {
            this.SetInProgress(true, "");
            this.IsFormEnabled = false;
            string str1 = this.CommonFieldsViewModel.Domain != this.CommonFieldsViewModel.CurrentDomain ? this.CommonFieldsViewModel.Domain : (string)null;

            if (str1 == "")
            {
                str1 = "club" + (object)this.CommunityId;
            }
            int  num1      = 0;
            bool?nullable1 = this.CommunityTypeSelectionViewModel.IsClosedSelected;
            bool flag1     = true;

            if ((nullable1.GetValueOrDefault() == flag1 ? (nullable1.HasValue ? 1 : 0) : 0) != 0)
            {
                num1 = 1;
            }
            nullable1 = this.CommunityTypeSelectionViewModel.IsPrivateSelected;
            bool flag2 = true;

            if ((nullable1.GetValueOrDefault() == flag2 ? (nullable1.HasValue ? 1 : 0) : 0) != 0)
            {
                num1 = 2;
            }
            int num2 = 1;

            nullable1 = this.AgeLimitsViewModel.From16Only;
            bool flag3 = true;

            if ((nullable1.GetValueOrDefault() == flag3 ? (nullable1.HasValue ? 1 : 0) : 0) != 0)
            {
                num2 = 2;
            }
            nullable1 = this.AgeLimitsViewModel.From18Only;
            bool flag4 = true;

            if ((nullable1.GetValueOrDefault() == flag4 ? (nullable1.HasValue ? 1 : 0) : 0) != 0)
            {
                num2 = 3;
            }
            string str2 = (string)null;

            if (this._information.Type == GroupType.PublicPage)
            {
                string str3 = this.FoundationDateViewModel.Day.Id.ToString();
                string str4 = this.FoundationDateViewModel.Month.Id.ToString();
                string str5 = this.FoundationDateViewModel.Year.Id.ToString();
                if (str3.Length == 1)
                {
                    str3 = "0" + str3;
                }
                if (str4.Length == 1)
                {
                    str4 = "0" + str4;
                }
                if (str5.Length == 1)
                {
                    str5 = "0000";
                }
                str2 = string.Format("{0}.{1}.{2}", (object)str3, (object)str4, (object)str5);
            }
            GroupPrivacy accessLevel = GroupPrivacy.Public;

            if (num1 == 1)
            {
                accessLevel = GroupPrivacy.Closed;
            }
            if (num1 == 2)
            {
                accessLevel = GroupPrivacy.Private;
            }
            string categoryName    = (string)null;
            string subcategoryName = (string)null;

            if (this.CommonFieldsViewModel.Category != null && this.CommonFieldsViewModel.Category.Id != 0L)
            {
                categoryName = this.CommonFieldsViewModel.Category.Name;
            }
            if (this.CommonFieldsViewModel.Subcategory != null && this.CommonFieldsViewModel.Subcategory.Id != 0L)
            {
                subcategoryName = this.CommonFieldsViewModel.Subcategory.Name;
            }
            long?    nullable2      = new long?();
            DateTime eventStartDate = new DateTime();
            DateTime dateTime       = new DateTime();

            if (this._information.Type == GroupType.Event)
            {
                nullable2 = new long?(this.EventOrganizerViewModel.Organizer.Id < 0L ? -this.EventOrganizerViewModel.Organizer.Id : 0L);
                DateTime startDate = this.EventDatesViewModel.StartDate;
                DateTime startTime = this.EventDatesViewModel.StartTime;
                eventStartDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, 0, DateTimeKind.Local);
                DateTime finishDate = this.EventDatesViewModel.FinishDate;
                DateTime finishTime = this.EventDatesViewModel.FinishTime;
                dateTime = new DateTime(finishDate.Year, finishDate.Month, finishDate.Day, finishTime.Hour, finishTime.Minute, 0, DateTimeKind.Local);
            }
            GroupsService        current      = GroupsService.Current;
            long                 communityId  = this.CommunityId;
            string               name         = this.CommonFieldsViewModel.Name;
            string               description  = this.CommonFieldsViewModel.Description;
            long                 id           = this.CommonFieldsViewModel.Category.Id;
            CustomListPickerItem subcategory1 = this.CommonFieldsViewModel.Subcategory;
            long                 subcategory2 = subcategory1 != null ? subcategory1.Id : 0L;
            string               site         = this.CommonFieldsViewModel.Site;
            int    accessLevel1     = num1;
            string domain           = str1;
            int    ageLimits        = num2;
            string foundationDate   = str2;
            long?  eventOrganizerId = nullable2;
            string phone            = this.EventOrganizerViewModel.Phone;
            string email            = this.EventOrganizerViewModel.Email;
            int    unixTimestamp1   = Extensions.DateTimeToUnixTimestamp(eventStartDate.ToUniversalTime(), false);
            int    unixTimestamp2   = Extensions.DateTimeToUnixTimestamp(dateTime.ToUniversalTime(), false);
            Action <BackendResult <int, ResultCode> > callback = (Action <BackendResult <int, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    EventAggregator.Current.Publish((object)new CommunityInformationChanged()
                    {
                        Id = this.CommunityId,
                        Name = this.CommonFieldsViewModel.Name,
                        Privacy = accessLevel,
                        CategoryName = categoryName,
                        SubcategoryName = subcategoryName,
                        EventStartDate = eventStartDate
                    });
                    Navigator.Current.GoBack();
                }
                else
                {
                    this.SetInProgress(false, "");
                    this.IsFormEnabled = true;
                    VKRequestsDispatcher.Error error = result.Error;
                    switch (error != null ? error.error_text : (string)null)
                    {
                    case null:
                        GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", result.Error);
                        break;

                    default:
                        result.Error.error_text += ".";
                        goto case null;
                    }
                }
            })));

            current.SetCommunityInformation(communityId, name, description, id, subcategory2, site, accessLevel1, domain, ageLimits, foundationDate, eventOrganizerId, phone, email, unixTimestamp1, unixTimestamp2, callback);
        }