Esempio n. 1
0
        public static Account MapFromObject(vAccount view)
        {
            if (view == null)
            {
                return(null);
            }

            var account = new Account()
            {
                AccountId    = view.AccountId,
                SubNo        = (view.SubNo >= 0) ? view.SubNo : (int?)null,
                ShredNo      = (view.ShredNo >= 0) ? view.ShredNo : (int?)null,
                Description  = view.Description,
                AnnualBudget = view.AnnualBudget,
                //Transfers Are populated outside of map,
                AccountNumber      = view.AccountNumber,
                FundNumber         = view.FundNumber,
                ProjectNumber      = view.ProjectNumber,
                ProjectDescription = view.ProjectDescription,
                AccountPrefix      = view.AccountPrefix,
                ChildAccounts      = new List <Account>()
            };

            return(account);
        }
Esempio n. 2
0
        public List <vAccount> ChildAccounts(vAccount account)
        {
            List <vAccount> childAccounts = new List <vAccount>();

            if (!account.ShredNo.HasValue)
            {
                for (var i = 0; i < 2; i++)
                {
                    childAccounts.Add(new vAccount()
                    {
                        AccountNumber         = account.AccountNumber,
                        SubNo                 = (account.SubNo.HasValue) ? account.SubNo : i,
                        ShredNo               = (account.SubNo.HasValue) ? i : (int?)null,
                        Description           = $"Child Account {i}",
                        AnnualBudget          = (decimal)i,
                        FundNumber            = i,
                        ProjectNumber         = $"Project {i}",
                        AccountPrefix         = $"-AA{i}",
                        RegionalAccountCodeId = i
                    });
                }
            }

            return(childAccounts);
        }
Esempio n. 3
0
        public ActionResult Register(vAccount acc)
        {
            UserControllers uscontrol = new UserControllers();
            bool            rs        = false;

            foreach (var item in uscontrol.GetallUser())
            {
                if (item.UserName == acc.UserName)
                {
                    rs = true;
                }
            }
            if (rs == true)
            {
                ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng.");
                return(View());
            }
            else
            {
                acc.UserId = Guid.NewGuid();
                bool kq = uscontrol.InsertUser(acc);
                if (kq == true)
                {
                    return(RedirectToAction("Login", "Login"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm không thành công. Đã có lỗi xảy ra");
                    return(View());
                }
            }
        }
Esempio n. 4
0
        public ActionResult Delete(Guid id)
        {
            UserControllers usontrol = new UserControllers();
            vAccount        acc      = usontrol.GetallUser().Find(x => x.UserId == id);

            usontrol.DeleteUser(acc);
            return(Json(new { rs = "ok" }));
        }
Esempio n. 5
0
        public ActionResult Create(vAccount user)
        {
            UserControllers usontrol = new UserControllers();

            user.UserId = Guid.NewGuid();
            usontrol.InsertUser(user);
            return(RedirectToAction("Index", "Account"));
        }
Esempio n. 6
0
 public ActionResult Edit(vAccount acc)
 {
     if (ModelState.IsValid)
     {
         UserControllers ucontroll = new UserControllers();
         ucontroll.UpdateUser(acc);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Esempio n. 7
0
        /// <summary>
        /// Retrives the children of the provided account. Returns an empty list if it has not children
        /// </summary>
        /// <param name="accountView"></param>
        /// <returns></returns>
        private Account _getAccountWithChildren(vAccount accountView)
        {
            var account = Account.MapFromObject(accountView);

            var childAccounts = _accountRepository.GetChildAccounts(accountView);

            foreach (var childAccount in childAccounts)
            {
                var subAccount = _getAccountWithChildren(childAccount);
                account.ChildAccounts.Add(subAccount);
            }

            return(account);
        }
Esempio n. 8
0
        public vAccount SingleAccount()
        {
            var account = new vAccount()
            {
                AccountNumber         = 1234,
                SubNo                 = 5,
                ShredNo               = 6,
                Description           = $"Test Account",
                AnnualBudget          = (decimal)100.00,
                FundNumber            = 96,
                ProjectNumber         = $"Test Project",
                AccountPrefix         = $"-Test",
                RegionalAccountCodeId = 987
            };

            return(account);
        }
Esempio n. 9
0
        public ActionResult Login(vAccount acc)
        {
            UserControllers uscl = new UserControllers();
            vAccount        kq   = uscl.checkLogin(acc);

            if (kq.UserId == Guid.Empty)
            {
                ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng");
                return(View());
            }
            else
            {
                Session.Add(CommonStant.SESSION_USER, kq);
                FormsAuthentication.SetAuthCookie(kq.UserName, kq.RememberMe);
                return(RedirectToAction("Home", "Admin"));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the Immediate Children of the provided account
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public List <vAccount> GetChildAccounts(vAccount account)
        {
            if (!account.ShredNo.HasValue && account.SubNo.HasValue)
            {
                return(_getShredoutAccounts(account.AccountNumber, account.SubNo.Value));
            }

            else if (!account.SubNo.HasValue)
            {
                return(_getSubAccounts(account.AccountNumber));
            }

            else
            {
                return(new List <vAccount>());
            }
        }