예제 #1
0
        public List <AddressItemModel> List(ApiCall apiCall)
        {
            var user  = apiCall.Context.User;
            var orgdb = Kooboo.Mail.Factory.DBFactory.OrgDb(user.CurrentOrgId);

            var addlist = orgdb.EmailAddress.Query().Where(o => o.UserId == user.Id).SelectAll();

            return(addlist.Select(o => AddressItemModel.FromAddress(o)).OrderBy(o => o.Address).ToList());
        }
        private void ListViewItemSelected(AddressItemModel item)
        {
            if (item == null)
            {
                return;
            }

            ListView.SelectedItem = null;
        }
예제 #3
0
        private async Task RefreshAddressTransactions(AddressItemModel addressItemModel)
        {
            var address      = (AddressItem)addressItemModel.Tag;
            var transactions = await transactionManager.AddTransactions(address.Transactions.Select(t => t.Hash).ToArray());

            if (!addressItemModel.HasWithdrawal)
            {
                addressItemModel.HasWithdrawal = transactions.Any(t => long.Parse(t.Value) < 0);
            }
        }
예제 #4
0
        public List <AddressItemModel> List(ApiCall apiCall)
        {
            if (EmailForwardManager.RequireForward(apiCall.Context))
            {
                return(EmailForwardManager.Get <List <AddressItemModel> >(this.ModelName, nameof(EmailAddressApi.List), apiCall.Context.User));
            }
            var user  = apiCall.Context.User;
            var orgdb = Kooboo.Mail.Factory.DBFactory.OrgDb(user.CurrentOrgId);

            var addlist = orgdb.EmailAddress.Query().Where(o => o.UserId == user.Id).SelectAll();

            return(addlist.Select(o => AddressItemModel.FromAddress(o)).OrderBy(o => o.Address).ToList());
        }
예제 #5
0
        public object Post(ApiCall apiCall)
        {
            if (EmailForwardManager.RequireForward(apiCall.Context))
            {
                var json = Kooboo.Lib.Helper.JsonHelper.Serialize(apiCall.Context.Request.Model);
                return(EmailForwardManager.Post <object>(this.ModelName, nameof(EmailAddressApi.Post), apiCall.Context.User, json, null));
            }

            var model   = apiCall.Context.Request.Model as AddressModel;
            var user    = apiCall.Context.User;
            var orgdb   = Kooboo.Mail.Factory.DBFactory.OrgDb(user.CurrentOrgId);
            var address = new EmailAddress
            {
                Address        = model.ToEmail().ToLower(),
                ForwardAddress = model.ForwardAddress,
                AddressType    = model.AddressType,
                UserId         = user.Id
            };

            if (!Kooboo.Mail.Utility.AddressUtility.IsValidEmailAddress(address.Address))
            {
                return(new Kooboo.Api.ApiResponse.JsonResponse
                {
                    Success = false,
                    Messages = new List <string> {
                        Kooboo.Data.Language.Hardcoded.GetValue("Invalid address format", apiCall.Context)
                    }
                });
            }

            if (address.AddressType == EmailAddressType.Forward)
            {
                address.ForwardAddress = address.ForwardAddress.ToLower();
                if (address.Address == address.ForwardAddress)
                {
                    return(new Kooboo.Api.ApiResponse.JsonResponse
                    {
                        Success = false,
                        Messages = new List <string> {
                            "Forward to address should not be same as forward from"
                        }
                    });
                }
            }

            orgdb.EmailAddress.AddOrUpdate(address);

            return(AddressItemModel.FromAddress(address));
        }
예제 #6
0
            public static AddressItemModel FromAddress(EmailAddress address)
            {
                var result = new AddressItemModel
                {
                    AddressOld     = address,
                    AddressType    = address.AddressType,
                    Address        = address.Address,
                    Id             = address.Id,
                    UserId         = address.UserId,
                    ForwardAddress = address.ForwardAddress,
                };

                if (address.AddressType == EmailAddressType.Group)
                {
                    result.Count = address.Members.Count();
                }

                return(result);
            }
        private void PickerItemSelected(AddressItemModel item)
        {
            if (item == null)
            {
                return;
            }

            var bettingViewModel = ViewModelContext as BettingViewModel;

            if (bettingViewModel != null)
            {
                var bettingItem = bettingViewModel.SelectedItem;

                bettingItem.Address  = item.Address;
                bettingItem.WalletId = item.WalletId;

                bettingViewModel.SelectedItem = bettingItem;

                Navigation.PopModalAsync();
            }
        }
예제 #8
0
        private AddressItemModel CreateAddressItemModel(Borlay.Iota.Library.Models.AddressItem addressItem)
        {
            var existing = addressesModel.ContentItems.FirstOrDefault(a => a.Address == addressItem.Address);

            if (existing != null)
            {
                return(existing);
            }

            var addressItemModel = new AddressItemModel((a) => OpenSend(a), a => Borlay.Iota.Library.Utils.Checksum.AddChecksum(a))
            {
                Tag = addressItem
            };

            addressesModel.ContentItems.Add(addressItemModel);
            addressItem.BindTo(addressItemModel, d => d.Address, m => m.Address);
            addressItem.BindTo(addressItemModel, d => d.Balance, m => m.Balance);
            addressItem.Changed(a => a.Balance, (a, v) => RefreshBalanceStats());


            return(addressItemModel);
        }