Example #1
0
 protected void btnforgetpsw_Click(object sender, EventArgs e)
 {
     try
     {
         BusinessLayer.AccountManager accMgr = new BusinessLayer.AccountManager();
         Entities.Account             entObj = new Entities.Account();
         string Emailid = txtfemail.Text;
         if (Emailid != string.Empty)
         {
             DataTable dtmailchk = new DataTable();
             dtmailchk = accMgr.ForgetemailBLL(Emailid);
             if (dtmailchk.Rows.Count > 0)
             {
                 Response.Write("<script language='javascript'>window.alert('Please check your inbox, we have sent you reset password url');</script>");
                 txtfemail.Text            = "";
                 dvsignup.Style["display"] = "none";
                 dvlogin.Style["display"]  = "block";
                 dvforget.Style["display"] = "none";
                 txtusername.Focus();
             }
             else
             {
                 Response.Write("<script language='javascript'>window.alert('Your email does not exist. Please enter a valid email.');</script>");
             }
         }
     }
     catch { }
 }
Example #2
0
        public void Connect()
        {
            // do smthng
            var basec=new Entities.Instrument(1,"UXU2","FUTUX",Entities.InstrumentType.Futures,"UX-9.13");
            basec.MaturityDate = new DateTime(2013,6,15);
            TimeSpan diff = basec.MaturityDate - DateTime.Now;
            basec.DaysToMate = (int)diff.TotalDays;
            this._instrumentslist.Add(basec);
            var opt1 = new Entities.Instrument(2, "UX000850BU3", "OPTUX", Entities.InstrumentType.Option, "UX 850 Put", Entities.OptionType.Put, 850, basec.Id);
            opt1.DaysToMate = 15;
            var opt2 = new Entities.Instrument(3, "UX000900BI3", "OPTUX", Entities.InstrumentType.Option, "UX 900 Call", Entities.OptionType.Call, 900, basec.Id);
            opt2.DaysToMate = 15;
            var opt3 = new Entities.Instrument(4, "UX000950BI3", "OPTUX", Entities.InstrumentType.Option, "UX 950 Call", Entities.OptionType.Call, 950, basec.Id);
            opt3.DaysToMate = 15;
            this._instrumentslist.Add(opt1);
            this._instrumentslist.Add(opt2);
            this._instrumentslist.Add(opt3);

            this._positionslist.Add(new Entities.Position(basec,-25,0,0));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i=>i.Id==2),10,2,4));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i=>i.Id==3),-5,2,4));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i=>i.Id==4),2,2,4));

            var acc=new Entities.Account("my_acc",2);
            this._portfolioslist.Add(new Entities.Portfolio(basec.Id,acc,this._positionslist));
            this._portfolioslist.ElementAt(0).Name = "Test portfolio";
        }
Example #3
0
        public void ExecuteTest()
        {
            var TEST_VALUE = Kipon.Solid.Plugin.Plugins.Account.AccountMergeImageUpdate.TEST_VALUE;

            using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.AccountMergeImageUpdate>())
            {
                var account = new Entities.Account {
                    AccountId = Guid.NewGuid()
                };
                account.AccountNumber = TEST_VALUE;
                ctx.AddEntity(account);

                ctx.OnPre = delegate
                {
                    var acc = ctx.GetEntityById <Entities.Account>(account.AccountId.Value);
                    Assert.AreEqual($"Assigned: {TEST_VALUE}", acc.Description);
                    Assert.AreEqual($"Assigned: {TEST_VALUE}", acc.AccountNumber);
                };

                var target = new Entities.Account {
                    AccountId = account.AccountId.Value, Name = TEST_VALUE
                };
                ctx.Update(target);
            }
        }
        public async Task <ResponseModel> Handle(CreateAccountCommand request, CancellationToken cancellationToken)
        {
            UserManager <Entities.Account> userManager = request.userManager;

            var userExists = await userManager.FindByNameAsync(request.Login);

            if (userExists != null)
            {
                throw new AccountAlreadyExistsException();
            }

            Entities.Account user = new Entities.Account()
            {
                UserName      = request.Login,
                FirstName     = request.FirstName,
                LastName      = request.LastName,
                SecurityStamp = Guid.NewGuid().ToString()
            };
            var result = await userManager.CreateAsync(user, request.Password);

            if (!result.Succeeded)
            {
                throw new AccountCreationFailedException();
            }
            return(new CreateAccountResponse(HttpStatusCode.OK, user.Id));
        }
Example #5
0
        public ErrorCodes Insert(Entities.Account user)
        {
            ErrorCodes errorCodes = ErrorCodes.Success;

            try
            {
                //if (!UserService.IsLogin())
                //{
                //    return ErrorCodes.NotLogin;
                //}

                if (user == null || string.IsNullOrEmpty(user.UserName) || string.IsNullOrEmpty(user.Password))
                {
                    return(ErrorCodes.BusinessError);
                }

                _accountDal.Insert(user);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
                errorCodes = ErrorCodes.Exception;
            }
            return(errorCodes);
        }
Example #6
0
        public Entities.Account GetByEmail(string email)
        {
            string storeName = "Admin_Account_GetByEmail";

            Entities.Account result = new Entities.Account();
            try
            {
                using (var db = new PostgresSQL(ConnectionEntity.DBPosition.Master))
                {
                    using (var command = db.CreateCommand(storeName, true))
                    {
                        command.Parameters.Add(NpgsqlParameter("@_email", email));
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                reader.Read();
                                EntityBase.SetObjectValue(reader, ref result);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0} => {1}", storeName, ex.ToString()));
            }
            return(result);
        }
 public Entities.Account StaffAddBLL(string txtStaffname, string txtMobileNo, string txtemail, string staffcode, string centrecode)
 {
     DataAccessLayer.RTOAdmin.RTOCounterStaffServiceDAO accDAO1 = new DataAccessLayer.RTOAdmin.RTOCounterStaffServiceDAO();
     Entities.Account entObj1 = new Entities.Account();
     entObj1 = accDAO1.StaffAddDAL(txtStaffname, txtMobileNo, txtemail, staffcode, centrecode);
     return(entObj1);
 }
Example #8
0
        public ActionResult Edit(int id)
        {
            AccountVM  viewModel = new AccountVM();
            AccountBAL balObject = new AccountBAL();
            IQueryable <Entities.Account> entites = balObject.FindBy(a => a.SrNo == id);

            if (entites != null && entites.Count() > 0)
            {
                Entities.Account entity = entites.FirstOrDefault();
                viewModel.SrNo             = entity.SrNo;
                viewModel.NarrationDetails = entity.NarrationDetails;
                viewModel.TransactionType  = entity.TransactionType;
                viewModel.PaymentMode      = entity.PaymentMode;
                viewModel.Amount           = entity.Amount;
                viewModel.Balance          = entity.Balance;
                viewModel.TransactionDate  = entity.TransactionDate;
                viewModel.Remark           = entity.Remark;

                viewModel.CustomerName = entity.CustomerName;
                viewModel.BankName     = entity.BankName;
                viewModel.ChqDDNumber  = entity.ChqDDNumber;
                viewModel.ContactNo    = entity.ContactNo;
            }
            return(View(viewModel));
        }
Example #9
0
        public void PreUpdateTest()
        {
            using (var ctx = PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.AccountPlugin>())
            {
                var pre = new Entities.Account
                {
                    AccountId = Guid.NewGuid(),
                    Name      = "Prename"
                };
                ctx.AddEntity(pre);

                var target = new Entities.Account
                {
                    AccountId = pre.AccountId,
                    Name      = "the next name"
                };

                ctx.OnPre = delegate()
                {
                    var result = ctx.GetEntityById <Entities.Account>(pre.AccountId.Value);
                    Assert.AreEqual("The Next Name", result.Name);
                    Assert.AreEqual(pre.Name, result.Description);
                };

                ctx.Update(target);
            }
        }
Example #10
0
        public void TargetAttributesTest()
        {
            /*
             * using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType<Kipon.Solid.Plugin.Plugins.Account.UseTargetAttributesPlugin>())
             * {
             *  var target = new Entities.Account { AccountId = Guid.NewGuid(), Name = "A name" };
             *  ctx.OnPre = delegate
             *  {
             *      Assert.AreEqual("FALSE", target.Description);
             *  };
             *
             *  ctx.Create(target);
             * }*/

            using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.UseTargetAttributesPlugin>())
            {
                var id  = Guid.NewGuid();
                var pre = new Entities.Account {
                    AccountId = id, Name = "A name", Telephone1 = "11111111"
                };

                ctx.AddEntity(pre);

                var target = new Entities.Account {
                    AccountId = id, Telephone1 = "22222222"
                };

                ctx.OnPre = delegate
                {
                    Assert.AreEqual("TRUE 11111111", target.Description);
                };

                ctx.Update(target);
            }
        }
Example #11
0
        public void Connect()
        {
            // do smthng
            var basec = new Entities.Instrument(1, "UXU2", "FUTUX", Entities.InstrumentType.Futures, "UX-9.13");

            basec.MaturityDate = new DateTime(2013, 6, 15);
            TimeSpan diff = basec.MaturityDate - DateTime.Now;

            basec.DaysToMate = (int)diff.TotalDays;
            this._instrumentslist.Add(basec);
            var opt1 = new Entities.Instrument(2, "UX000850BU3", "OPTUX", Entities.InstrumentType.Option, "UX 850 Put", Entities.OptionType.Put, 850, basec.Id);

            opt1.DaysToMate = 15;
            var opt2 = new Entities.Instrument(3, "UX000900BI3", "OPTUX", Entities.InstrumentType.Option, "UX 900 Call", Entities.OptionType.Call, 900, basec.Id);

            opt2.DaysToMate = 15;
            var opt3 = new Entities.Instrument(4, "UX000950BI3", "OPTUX", Entities.InstrumentType.Option, "UX 950 Call", Entities.OptionType.Call, 950, basec.Id);

            opt3.DaysToMate = 15;
            this._instrumentslist.Add(opt1);
            this._instrumentslist.Add(opt2);
            this._instrumentslist.Add(opt3);

            this._positionslist.Add(new Entities.Position(basec, -25, 0, 0));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i => i.Id == 2), 10, 2, 4));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i => i.Id == 3), -5, 2, 4));
            this._positionslist.Add(new Entities.Position(_instrumentslist.FirstOrDefault(i => i.Id == 4), 2, 2, 4));

            var acc = new Entities.Account("my_acc", 2);

            this._portfolioslist.Add(new Entities.Portfolio(basec.Id, acc, this._positionslist));
            this._portfolioslist.ElementAt(0).Name = "Test portfolio";
        }
Example #12
0
        public IEnumerable <Entities.Account> GetAll()
        {
            string storeName = "Admin_Account_GetAll";
            var    lst       = new List <Entities.Account>();

            try
            {
                using (var db = new PostgresSQL(ConnectionEntity.DBPosition.Master))
                {
                    using (var command = db.CreateCommand(storeName, true))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    var obj = new Entities.Account();
                                    EntityBase.SetObjectValue(reader, ref obj);
                                    lst.Add(obj);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0} => {1}", storeName, ex.ToString()));
            }
            return(lst);
        }
Example #13
0
        public void ExecuteDoNotHitTest()
        {
            using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.AccoutPostUpdate>())
            {
                var account = new Entities.Account {
                    AccountId = Guid.NewGuid()
                };
                account.AccountNumber     = Kipon.Solid.Plugin.Plugins.Account.AccoutPostUpdate.TEST_POST_UPDATE_ACCOUNTNUMBER;
                account.Name              = "A test value";
                account.AccountRatingCode = new Microsoft.Xrm.Sdk.OptionSetValue(1);
                ctx.AddEntity(account);

                Kipon.Solid.Plugin.Service.AccountService.POST_MERGE_TEST = "DO_NOT_HIT";
                string expect = "DO_NOT_HIT";

                ctx.OnPost = delegate
                {
                    Assert.AreEqual(Kipon.Solid.Plugin.Service.AccountService.POST_MERGE_TEST, expect);
                };


                var target = new Entities.Account {
                    AccountId = account.AccountId.Value, Address1_City = "København"
                };
                ctx.Update(target);
            }
        }
Example #14
0
 public void Superadmindetails()
 {
     try
     {
         BusinessLayer.AccountManager accMgr = new BusinessLayer.AccountManager();
         Entities.Account             entObj = new Entities.Account();
         BusinessLayer.PasswordEncryp pwd    = new BusinessLayer.PasswordEncryp();
         DataTable dt = new DataTable();
         dt = accMgr.SuperadmindetailsBLL();
         if (dt.Rows.Count > 0)
         {
             string Name    = dt.Rows[0]["SuperAdminName_VCR"].ToString();
             string Email   = dt.Rows[0]["SuperAdminEmailID_VCR"].ToString();
             string Phone   = dt.Rows[0]["SuperAdminMobileNo_VCR"].ToString();
             string Address = dt.Rows[0]["SuperAdminAddress_VCR"].ToString();
             txtname.Text      = Name;
             txtemail.Text     = Email;
             txtemail.ReadOnly = true;
             txtphone.Text     = Phone;
             txtaddress.Text   = Address;
         }
     }
     catch (Exception ex)
     {
     }
 }
        public async Task <int> AddTransaction(Guid fromAccount, Guid toAccount, int amount)
        {
            try
            {
                Entities.Account fAccount = await _context.Accounts.FirstOrDefaultAsync(a => a.AccountId == fromAccount);

                Entities.Account tAccount = await _context.Accounts.FirstOrDefaultAsync(a => a.AccountId == toAccount);

                if (!CheckAccountExistance(fAccount) || !CheckAccountExistance(tAccount))
                {
                    return(2);
                }
                if (!CheckBalance(amount, fAccount.Balance))
                {
                    return(2);
                }
                fAccount.Balance -= amount;
                tAccount.Balance += amount;
                _context.SaveChanges();
                return(1);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #16
0
        public void UpdateAccount(WhatYouGotLibrary.Models.Account account)
        {
            Entities.Account currentAccount = _context.Account.Find(account.Id);
            Entities.Account newAccount     = Mapper.Map(account);

            _context.Entry(currentAccount).CurrentValues.SetValues(newAccount);
        }
Example #17
0
        public void TestGetAccount()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            using (var sqliteMemoryWrapper = new SqliteMemoryWrapper())
            {
                var currencyFactory   = new CurrencyFactory();
                var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true);
                currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity);

                var accountFactory = new AccountFactory();
                Entities.Account checkingAccountEntity = accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity);

                var accountService = new AccountService(loggerFactory, sqliteMemoryWrapper.DbContext);

                Account checkingAccount = accountService.Get(checkingAccountEntity.AccountId);

                Assert.AreEqual(checkingAccountEntity.AccountId, checkingAccount.AccountId);
                Assert.AreEqual(checkingAccountEntity.Name, checkingAccount.Name);
                Assert.AreEqual(AccountType.Asset, checkingAccount.Type);
                Assert.AreEqual(usdCurrencyEntity.CurrencyId, checkingAccount.Currency.CurrencyId);
                Assert.AreEqual(usdCurrencyEntity.IsPrimary, checkingAccount.Currency.IsPrimary);
                Assert.AreEqual(usdCurrencyEntity.Name, checkingAccount.Currency.Name);
                Assert.AreEqual(usdCurrencyEntity.ShortName, checkingAccount.Currency.ShortName);
                Assert.AreEqual(usdCurrencyEntity.Symbol, checkingAccount.Currency.Symbol);
            }
        }
Example #18
0
 public System.Data.DataTable CheckLogindetailsBLL(string email, string password)
 {
     DataAccessLayer.AccountManagerDAO accDAO1 = new DataAccessLayer.AccountManagerDAO();
     Entities.Account      entObj1             = new Entities.Account();
     System.Data.DataTable dt1 = new System.Data.DataTable();
     dt1 = accDAO1.CheckLogindetailsBLL(email, password);
     return(dt1);
 }
 public void OnPreUpdate(
     Entities.Account target,
     Microsoft.Xrm.Sdk.IOrganizationService orgService,
     Kipon.Solid.Plugin.Entities.IAdminUnitOfWork aUow,
     Kipon.Solid.Plugin.ServiceAPI.IAccountService accountService,
     Kipon.Solid.Plugin.Entities.Account.IAccountNameChanged account)
 {
 }
 public System.Data.DataTable FillstaffBLL(string centercode)
 {
     DataAccessLayer.RTOAdmin.RTOCounterStaffServiceDAO accDAO1 = new DataAccessLayer.RTOAdmin.RTOCounterStaffServiceDAO();
     Entities.Account      entObj = new Entities.Account();
     System.Data.DataTable dt1    = new System.Data.DataTable();
     dt1 = accDAO1.FillstaffDAL(centercode);
     return(dt1);
 }
Example #21
0
        public void Register(Entities.Account account)
        {
            var unitOfWork        = UnitWorkFactory.GetUnitOfWork();
            var accountRepositary = unitOfWork.GetRepository <Entities.Account>();

            accountRepositary.Add(account);
            unitOfWork.SaveChanges();
        }
 public bool CheckAccountExistance(Entities.Account account)
 {
     if (account == null)
     {
         throw new Exception("No such account found");
     }
     return(true);
 }
Example #23
0
 public System.Data.DataTable CheckSuperadmindetailsBLL()
 {
     DataAccessLayer.AccountManagerDAO accDAO1 = new DataAccessLayer.AccountManagerDAO();
     Entities.Account      entObj1             = new Entities.Account();
     System.Data.DataTable dt1 = new System.Data.DataTable();
     dt1 = accDAO1.CheckSuperadmindetailsDAL();
     return(dt1);
 }
Example #24
0
 public (bool Success, string Content, int Model) CreateAccount(Entities.Account account)
 {
     return(new HttpServiceHelper().POST <Entities.Account, int>($"{this.Domain}account", account, headers: new Dictionary <string, string>
     {
         ["Content-Type"] = "application/json",
         ["Authorization"] = $"Bearer {this.Token}"
     }));
 }
        public void TestCreateManyTransactions()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            using (var sqliteMemoryWrapper = new SqliteMemoryWrapper())
            {
                var currencyFactory   = new CurrencyFactory();
                var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true);
                currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity);

                var accountFactory = new AccountFactory();
                Entities.Account incomeAccountEntity =
                    accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity);
                Entities.Account checkingAccountEntity =
                    accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity);

                var accountService = new AccountService(
                    loggerFactory,
                    sqliteMemoryWrapper.DbContext
                    );
                var transactionService = new TransactionService(
                    loggerFactory,
                    sqliteMemoryWrapper.DbContext
                    );
                var newTransactions = new Transaction[]
                {
                    new Transaction {
                        CreditAccount = accountService.GetAsLink(incomeAccountEntity.AccountId),
                        DebitAccount  = accountService.GetAsLink(checkingAccountEntity.AccountId),
                        Amount        = 100m,
                        At            = new DateTime(2018, 1, 1, 9, 0, 0)
                    },
                    new Transaction {
                        CreditAccount = accountService.GetAsLink(incomeAccountEntity.AccountId),
                        DebitAccount  = accountService.GetAsLink(checkingAccountEntity.AccountId),
                        Amount        = 70m,
                        At            = new DateTime(2018, 1, 1, 9, 25, 0)
                    }
                };
                transactionService.CreateMany(newTransactions);

                List <Entities.Transaction> transactionEntities = sqliteMemoryWrapper.DbContext.Transactions.ToList();

                Assert.AreEqual(2, transactionEntities.Count);
                Assert.AreEqual(newTransactions[0].TransactionId, transactionEntities[0].TransactionId);
                Assert.AreEqual(newTransactions[0].CreditAccount.AccountId, transactionEntities[0].CreditAccount.AccountId);
                Assert.AreEqual(newTransactions[0].DebitAccount.AccountId, transactionEntities[0].DebitAccount.AccountId);
                Assert.AreEqual(newTransactions[0].Amount, transactionEntities[0].Amount);
                Assert.AreEqual(newTransactions[0].At, transactionEntities[0].At);
                Assert.AreEqual(newTransactions[1].TransactionId, transactionEntities[1].TransactionId);
                Assert.AreEqual(newTransactions[1].CreditAccount.AccountId, transactionEntities[1].CreditAccount.AccountId);
                Assert.AreEqual(newTransactions[1].DebitAccount.AccountId, transactionEntities[1].DebitAccount.AccountId);
                Assert.AreEqual(newTransactions[1].Amount, transactionEntities[1].Amount);
                Assert.AreEqual(newTransactions[1].At, transactionEntities[1].At);
            }
        }
        public void TestGetAllAccountRelationships()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            using (var sqliteMemoryWrapper = new SqliteMemoryWrapper())
            {
                var currencyFactory   = new CurrencyFactory();
                var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true);
                currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity);

                var accountFactory = new AccountFactory();
                Entities.Account incomeAccountEntity =
                    accountFactory.Create(AccountPrefab.Income, usdCurrencyEntity);
                Entities.Account checkingAccountEntity =
                    accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity);
                Entities.Account groceriesPrepaymentAccountEntity =
                    accountFactory.Create(AccountPrefab.GroceriesPrepayment, usdCurrencyEntity);
                Entities.Account rentPrepaymentAccountEntity =
                    accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, incomeAccountEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, groceriesPrepaymentAccountEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity);

                var checkingToGroceriesPrepaymentRelationship = new Entities.AccountRelationship
                {
                    SourceAccount      = checkingAccountEntity,
                    DestinationAccount = groceriesPrepaymentAccountEntity,
                    Type = AccountRelationshipType.PhysicalToLogical
                };
                var checkingToRentPrepaymentRelationship = new Entities.AccountRelationship
                {
                    SourceAccount      = checkingAccountEntity,
                    DestinationAccount = rentPrepaymentAccountEntity,
                    Type = AccountRelationshipType.PhysicalToLogical
                };

                sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToGroceriesPrepaymentRelationship);
                sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship);
                sqliteMemoryWrapper.DbContext.SaveChanges();

                var accountRelationshipService = new AccountRelationshipService(loggerFactory, sqliteMemoryWrapper.DbContext);

                List <AccountRelationship> accountRelationships = accountRelationshipService.GetAll().ToList();

                Assert.AreEqual(2, accountRelationships.Count);
                Assert.AreEqual(AccountRelationshipType.PhysicalToLogical, accountRelationships[0].Type);
                Assert.AreEqual(checkingAccountEntity.AccountId, accountRelationships[0].SourceAccount.AccountId);
                Assert.AreEqual(checkingAccountEntity.Name, accountRelationships[0].SourceAccount.Name);
                Assert.AreEqual(groceriesPrepaymentAccountEntity.AccountId, accountRelationships[0].DestinationAccount.AccountId);
                Assert.AreEqual(groceriesPrepaymentAccountEntity.Name, accountRelationships[0].DestinationAccount.Name);
                Assert.AreEqual(AccountRelationshipType.PhysicalToLogical, accountRelationships[1].Type);
                Assert.AreEqual(checkingAccountEntity.AccountId, accountRelationships[1].SourceAccount.AccountId);
                Assert.AreEqual(checkingAccountEntity.Name, accountRelationships[1].SourceAccount.Name);
                Assert.AreEqual(rentPrepaymentAccountEntity.AccountId, accountRelationships[1].DestinationAccount.AccountId);
                Assert.AreEqual(rentPrepaymentAccountEntity.Name, accountRelationships[1].DestinationAccount.Name);
            }
        }
 public void OnPreCreate1(
     Entities.Account target,
     Entities.IAccountPreimage history,
     Entities.Account.IAccountNameChanged nameChanged,
     [Kipon.Xrm.Attributes.Target] Entities.Account someName,
     ServiceAPI.IAccountService accountService,
     Entities.IAccountMergedimage merged)
 {
 }
Example #28
0
        public IHttpActionResult Add(Entities.Account account)
        {
            Account accountModel = new Account();

            account.IsNew = true;
            accountModel.Save(account);

            return(Ok());//should be created
        }
Example #29
0
        public void TestAccountRelationshipEditViewModelOK()
        {
            ILoggerFactory loggerFactory = new LoggerFactory();

            using (var sqliteMemoryWrapper = new SqliteMemoryWrapper())
            {
                var currencyFactory   = new CurrencyFactory();
                var usdCurrencyEntity = currencyFactory.Create(CurrencyPrefab.Usd, true);
                currencyFactory.Add(sqliteMemoryWrapper.DbContext, usdCurrencyEntity);

                var accountFactory = new AccountFactory();
                Entities.Account checkingAccountEntity =
                    accountFactory.Create(AccountPrefab.Checking, usdCurrencyEntity);
                Entities.Account rentPrepaymentAccountEntity =
                    accountFactory.Create(AccountPrefab.RentPrepayment, usdCurrencyEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, checkingAccountEntity);
                accountFactory.Add(sqliteMemoryWrapper.DbContext, rentPrepaymentAccountEntity);

                var checkingToRentPrepaymentRelationship = new Entities.AccountRelationship
                {
                    SourceAccount      = checkingAccountEntity,
                    DestinationAccount = rentPrepaymentAccountEntity,
                    Type = AccountRelationshipType.PhysicalToLogical
                };

                sqliteMemoryWrapper.DbContext.AccountRelationships.Add(checkingToRentPrepaymentRelationship);
                sqliteMemoryWrapper.DbContext.SaveChanges();

                var accountService = new AccountService(
                    loggerFactory,
                    sqliteMemoryWrapper.DbContext);

                var accountRelationshipService = new AccountRelationshipService(
                    loggerFactory,
                    sqliteMemoryWrapper.DbContext);

                var viewModel = new AccountRelationshipEditViewModel(
                    loggerFactory,
                    accountService,
                    accountRelationshipService,
                    checkingToRentPrepaymentRelationship.AccountRelationshipId
                    );

                viewModel.SelectedType = AccountRelationshipType.PrepaymentToExpense;
                viewModel.OKCommand.Execute(this);

                List <AccountRelationship> accountRelationships = accountRelationshipService.GetAll().ToList();

                Assert.AreEqual(1, accountRelationships.Count);
                Assert.AreEqual(checkingToRentPrepaymentRelationship.SourceAccountId,
                                accountRelationships[0].SourceAccount.AccountId);
                Assert.AreEqual(checkingToRentPrepaymentRelationship.DestinationAccountId,
                                accountRelationships[0].DestinationAccount.AccountId);
                Assert.AreEqual(viewModel.SelectedType,
                                accountRelationships[0].Type);
            }
        }
        public async Task <AccountResult> GetAccount(Guid accountId)
        {
            using (IDbConnection db = new SqlConnection(_connectionString))
            {
                string           accountSQL = @"SELECT * FROM Account WHERE Id = @accountId";
                Entities.Account account    = await db
                                              .QueryFirstOrDefaultAsync <Entities.Account>(accountSQL, new { accountId });

                if (account == null)
                {
                    return(null);
                }

                string credits =
                    @"SELECT * FROM [Credit]
                      WHERE AccountId = @accountId";

                List <ITransaction> transactionsList = new List <ITransaction>();

                using (var reader = db.ExecuteReader(credits, new { accountId }))
                {
                    var parser = reader.GetRowParser <Credit>();

                    while (reader.Read())
                    {
                        ITransaction transaction = parser(reader);
                        transactionsList.Add(transaction);
                    }
                }

                string debits =
                    @"SELECT * FROM [Debit]
                      WHERE AccountId = @accountId";

                using (var reader = db.ExecuteReader(debits, new { accountId }))
                {
                    var parser = reader.GetRowParser <Debit>();

                    while (reader.Read())
                    {
                        ITransaction transaction = parser(reader);
                        transactionsList.Add(transaction);
                    }
                }

                TransactionCollection transactionCollection = new TransactionCollection();

                foreach (var item in transactionsList.OrderBy(e => e.TransactionDate))
                {
                    transactionCollection.Add(item);
                }

                Account       result        = Account.Load(account.Id, account.CustomerId, transactionCollection);
                AccountResult accountResult = new AccountResult(result);
                return(accountResult);
            }
        }
Example #31
0
        public Entities.Account Update(Entities.Account account)
        {
            var acc = _context.Accounts.Find(account.Id);

            acc.Role = account.Role;
            _context.Accounts.Update(acc);
            _context.SaveChanges();
            return(acc);
        }