Beispiel #1
0
        public Account CreateAccount(vAccount_obj_save ItemData)
        {
            Account objResult = new Account();
            var     Data      = _AccountsRepository.GetAll();

            if (Data.Any(a => a.IBAN == (ItemData.IBAN + "").Trim()))
            {
                objResult.Msg = "Dulpication IBAN";


                return(objResult);
            }

            if (!ItemData.amount.HasValue)
            {
                objResult.Msg = "amount is null or zero.";
                return(objResult);
            }

            DateTime dNow    = DateTime.Now;
            Accounts objSave = new Accounts()
            {
                update_user   = "******",
                update_date   = dNow,
                create_user   = "******",
                create_date   = dNow,
                active_status = "Y",
                IBAN          = (ItemData.IBAN + "").Trim(),
                AccTransfers  = new List <AccTransfers>(),
                balance       = ItemData.amount.Value * (decimal)0.99,
            };

            objSave.AccTransfers.Add(new AccTransfers
            {
                update_user   = "******",
                update_date   = dNow,
                create_user   = "******",
                create_date   = dNow,
                active_status = "Y",
                Amount        = ItemData.amount.Value * (decimal)0.99,
                is_calculated = "Y",
                action_type   = "D"
            });

            _AccountsRepository.Add(objSave);

            objResult.Data = new List <Account>()
            {
            };
            Data = _AccountsRepository.GetAll().ToList();
            return(objResult);
        }
Beispiel #2
0
        public Account Withdrawal(vAccount_obj_save ItemData)
        {
            DateTime dNow      = DateTime.Now;
            Account  objResult = new Account();
            var      Data      = _AccountsRepository.GetAll();

            if (!Data.Any(a => a.Id == ItemData.Id))
            {
                objResult.Msg = "Account not found.";
                return(objResult);
            }
            var accUser = Data.Where(w => w.Id == ItemData.Id).FirstOrDefault();

            if (!ItemData.amount.HasValue)
            {
                objResult.Msg = "amount is null or zero.";
                return(objResult);
            }
            if (accUser.balance < ItemData.amount)
            {
                objResult.Msg = "Unable to perform list.";
                return(objResult);
            }

            var objUser = new AccTransfers
            {
                update_user   = "******",
                update_date   = dNow,
                create_user   = "******",
                create_date   = dNow,
                active_status = "Y",
                Amount        = ItemData.amount.Value,
                is_calculated = "Y",
                action_type   = "W",
                Accounts_Id   = ItemData.Id
            };

            _AccTransfersRepository.Add(objUser);
            accUser.update_date = dNow;
            accUser.update_user = "******";
            accUser.balance     = accUser.balance - ItemData.amount.Value;

            _AccountsRepository.Update(accUser, accUser);

            objResult.Data = new List <Account>()
            {
            };
            Data = _AccountsRepository.GetAll().ToList();
            return(objResult);
        }