Пример #1
0
        public async Task <AjaxResult> FilterFund(int pageNumber, int pageSize, [FromBody] List <Filter> filters)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                await Task.Delay(100);

                string where = string.Empty;
                if (filters != null && filters.Count > 0)
                {
                    where = Filter.buidWhereFilterCondition(filters);
                }
                using (FundBL fundBL = new FundBL())
                {
                    List <Fund> fund = fundBL.PagingFundBL(where, pageNumber, pageSize);
                    ajaxresult.Data    = fund;
                    ajaxresult.Success = true;
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorSaveFund;
            }
            return(ajaxresult);
        }
Пример #2
0
        public AjaxResult Delete([FromBody] List <Guid> listID)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                using (FundBL fundBL = new FundBL())
                {
                    foreach (var id in listID)
                    {
                        fundBL.DeleteFundBL(id);
                    }
                    ajaxresult.Data = fundBL.GetAllFund();
                }

                ajaxresult.Success = true;
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorDeleteFund;
            }
            return(ajaxresult);
        }
Пример #3
0
 public ActionResult AddFriends([FromBody] UserAddObject date)
 {
     try {
         FundBL.AddFriends(date.Friends, date.FundId);
     } catch (Exception e) {
         return(BadRequest(e.ToString()));
     }
     return(Ok());
 }
Пример #4
0
        public ActionResult GetUsersToAdd([FromRoute] string id)
        {
            List <UserDTO> users;

            try {
                users = FundBL.GetUsersToAdd(id);
            } catch (Exception e) {
                return(BadRequest(e.ToString()));
            }
            return(Ok(users));
        }
Пример #5
0
        public ActionResult GetFundByID([FromRoute] string id)
        {
            FundDTO fund;

            try {
                fund = FundBL.GetById(id);
            } catch (Exception e) {
                return(BadRequest(e.ToString()));
            }
            return(Ok(fund));
        }
Пример #6
0
        public ActionResult GetFunds()
        {
            List <FundDTO> fList;

            try {
                fList = FundBL.GetList();
            } catch (Exception e) {
                return(BadRequest(e.ToString()));
            }
            return(Ok(fList));
        }
Пример #7
0
        public ActionResult getFutureBalances()
        {
            DateTime date      = DateTime.Now;
            int      thisMonth = date.Month;

            // int size =5;
            int[] FutureBalances = new int[6];
            for (int month = 0; month < 6; month++)
            {
                FutureBalances[month] = FundBL.GetFutureBalance("1", date);
                date = date.AddMonths(1);
            }
            return(Ok(FutureBalances));
        }
Пример #8
0
        public static void Update(RepaymentsDTO repayment)
        {
            db         DB           = new db();
            Repayments repaymentDal = DB.Repayments.FirstOrDefault(r => r.RepaymentId == repayment.Id);

            if (repayment.NameStatus == "performed" && repaymentDal.NameStatus != "performed")
            {
                FundBL.AddBalance(repayment.Amount);
            }
            repaymentDal.Amount     = repayment.Amount;
            repaymentDal.NameStatus = repayment.NameStatus;
            repaymentDal.Date       = repayment.Date;
            // repaymentDal.remark= repayment.Remark;
            DB.SaveChanges();
        }
Пример #9
0
        public static void Add(WithdrawalsDTO withdrawalDTO)
        {
            withdrawing withdrawal = WithdrawalsConvert.DTOtoDAL(withdrawalDTO);
            db          DB         = new db();

            DB.Withdrawing.Add(withdrawal);
            DB.SaveChanges();
            if (withdrawalDTO.Status == "performed")
            {
                FundBL.Subtract_Balance(withdrawalDTO.Amount, withdrawalDTO.FundId);
                User_in_fund user = DB.UserInFunds.FirstOrDefault(u => u.UserId == withdrawal.UserId && u.FundId == withdrawal.FundId);
                user.balance -= withdrawal.Amount;
            }
            DB.SaveChanges();
        }
Пример #10
0
        public AjaxResult PutFund([FromBody] Fund newFund)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                using (FundBL fundBL = new FundBL())
                {
                    fundBL.EditFundBL(newFund);
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorEditFund;
            }
            return(ajaxresult);
        }
Пример #11
0
        public AjaxResult GetIDPay()
        {
            var ajaxresult = new AjaxResult();

            try
            {
                using (FundBL fundBL = new FundBL())
                {
                    ajaxresult.Data    = fundBL.GetPayCodeAutoBL();
                    ajaxresult.Success = true;
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorNotify;
            }
            return(ajaxresult);
        }
Пример #12
0
        public AjaxResult GetIdByCode(string code)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                using (FundBL fundBL = new FundBL())
                {
                    ajaxresult.Data    = fundBL.GetFundByFundCodeBL(code);
                    ajaxresult.Success = true;
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorNotify;
            }
            return(ajaxresult);
        }
Пример #13
0
        public AjaxResult saveFund(Fund fund)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                using (FundBL fundBL = new FundBL())
                {
                    fundBL.CreateFundBL(fund);
                    ajaxresult.Success = true;
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorSaveFund;
            }
            return(ajaxresult);
        }
Пример #14
0
        public async Task <AjaxResult> GetAsync(Guid id)
        {
            var ajaxresult = new AjaxResult();

            try
            {
                await Task.Delay(100);

                using (FundBL fundBL = new FundBL())
                {
                    ajaxresult.Data    = fundBL.GetFundByIDBL(id);
                    ajaxresult.Success = true;
                }
            }
            catch (Exception ex)
            {
                ajaxresult.Success = false;
                ajaxresult.Data    = ex;
                ajaxresult.Message = Resources.ErrorGetFund;
            }
            return(ajaxresult);
        }
Пример #15
0
        public static void Updete(WithdrawalsDTO withdrawalDTO)
        {
            db          DB         = new db();
            withdrawing withdrawal = DB.Withdrawing.FirstOrDefault(w => w.Id == withdrawalDTO.Id);

            //if it changed to Approved
            if (withdrawal.NameStatus != "performed" && withdrawalDTO.Status == "performed")
            {
                FundBL.Subtract_Balance(withdrawalDTO.Amount, withdrawalDTO.FundId);
            }
            else
            {
                //if it was performed and changed to canceled
                if (withdrawal.NameStatus == "performed" && withdrawalDTO.Status == "canceled")
                {
                    FundBL.AddBalance(withdrawalDTO.Amount, withdrawalDTO.FundId);
                }
            }
            withdrawal.Amount = withdrawalDTO.Amount;
            withdrawal.Date   = withdrawalDTO.Date;
            // withdrawal.paymentMethod = withdrawalDTO.PaymentMethod;
            withdrawal.NameStatus = withdrawalDTO.Status;
            DB.SaveChanges();
        }
Пример #16
0
 public void Save([FromBody] FundDTO fund)
 {
     FundBL.Save(fund);
 }