コード例 #1
0
        private async Task SendInvite()
        {
            View.HideKeyboard();

            InviteEmailValidator validator   = new InviteEmailValidator();
            InviteEmail          inviteEmail = new InviteEmail(EmailInvite, mProjectItem.Invites);

            var result = validator.Validate(inviteEmail);

            if (result.IsValid)
            {
                mPlatformService.ShowNetworkIndicator();
                mProgressDialogService.ShowProgressDialog();

                var response = await mApiService.AddInvitee(mProjectItem.Id.Value, EmailInvite, null);

                Mvx.Resolve <ITrackingService>().SendEvent("Invite a user in edit project");

                mPlatformService.HideNetworkIndicator();
                mProgressDialogService.HideProgressDialog();

                if (response.StatusCode == System.Net.HttpStatusCode.OK && response.Data != null)
                {
                    Invite invite = response.Data;
                    InviteTrades.Add(new PendingTradesItemViewModel(this, invite)
                    {
                        PendingTrades = invite, EditProjectViewModel = this
                    });
                    mCacheService.ProjectItem.Invites.Add(invite);
                    mCacheService.EdittingProjectInvitee.Add(invite);
                    EmailInvite = string.Empty;
                }
                else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    mMessageboxService.ShowToast("Email is not exist");
                    EmailInvite = string.Empty;
                }
            }
            else if (result.Errors != null)
            {
                var firstError = result.Errors.First();
                mMessageboxService.ShowToast(firstError.ErrorMessage);
            }
        }
コード例 #2
0
        public void Init()
        {
            if (mCacheService.ProjectItem != null)
            {
                mProjectItem = mCacheService.ProjectItem;
                Title        = mProjectItem.Title;
                Description  = mProjectItem.Description;
                Stage        = mProjectItem.Stage;

                var invitesAccepted = mProjectItem.Invites.Where(s => s.JoinedProject != null);
                foreach (var item in invitesAccepted)
                {
                    mCurrentTracesStatic.Add(new CurrentTradesItemViewModel(this, item));
                }

                if (mCurrentTracesStatic.Count > 3)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        CurrentTrades.Add(mCurrentTracesStatic[i]);
                    }
                    IsShowMoreButton = true;
                }
                else
                {
                    foreach (var item in mCurrentTracesStatic)
                    {
                        CurrentTrades.Add(item);
                    }
                    IsShowMoreButton = false;
                }

                var intvitesPending = mProjectItem.Invites.Where(s => s.JoinedProject == null);
                foreach (var invite in intvitesPending)
                {
                    InviteTrades.Add(new PendingTradesItemViewModel(this, invite)
                    {
                        EditProjectViewModel = this, PendingTrades = invite
                    });
                }
            }

            RegisterMessengers();
        }