Exemple #1
0
        public IEnumerable <ExpenseViewModel> GetExpense()
        {
            var source      = _expenseRepository.GetAll();
            var destination = Mapper.Map <IEnumerable <Expense_M>, IEnumerable <ExpenseViewModel> >(source);

            return(destination);
        }
Exemple #2
0
        public async Task <ExpenseListViewModel> Upload(IFormFile fileForm, string fileName, int expenseId)
        {
            var viewModel = new ExpenseListViewModel();

            try
            {
                var expense = await _expenseRepository.Get(expenseId);

                if (fileForm != null && fileForm.Length > 0)
                {
                    using (var ms = new MemoryStream())
                    {
                        fileForm.CopyTo(ms);
                        var fileRawData   = ms.ToArray();
                        var salesDocument = new SalesDocumentForm()
                        {
                            ExpenseId   = expenseId,
                            Name        = fileName,
                            FileRawData = fileRawData
                        };
                        await _salesDocumentRepository.Create(salesDocument);
                    }
                }

                viewModel.VirtualAccountId = expense.VirtualAccountId;
                viewModel.Expenses         = await _expenseRepository.GetAll(expense.VirtualAccountId);
            }
            catch (Exception e)
            {
                viewModel.Error = new GackoError(e);
            }

            return(viewModel);
        }
 public async Task <ICollection <Expense> > GetIndividualExpensesAsync(string ownerUserId)
 {
     return(await _expenseRepository.GetAll()
            .Where(expense => expense.ExpenseOwner.OwnerUserId == ownerUserId)
            .Include(expense => expense.ExpenseClassification)
            .ToListAsync().ConfigureAwait(false));
 }
Exemple #4
0
        public static decimal CalculateTotalExpense(this IExpenseRepository expenseRepository,
                                                    Guid budgetId)
        {
            var totalExpense = expenseRepository.GetAll()
                               .Where(x => x.BudgetId == budgetId).Sum(z => z.Value);

            return(totalExpense);
        }
        public async Task <Response <List <ExpenseDTO> > > Handle(GetExpensesForPurchaseRecordRequest request, CancellationToken cancellationToken)
        {
            var expenseMappingProfile = new ExpenseMappingProfile();
            var expenses = await _repository.GetAll((expense) => expense.PurchaseRecordId == request.PurchaseRecordId);

            var result = expenses.Select((expense) => expenseMappingProfile.ToDto(expense)).ToList();

            return(new Response <List <ExpenseDTO> >(result));
        }
Exemple #6
0
        public async Task <IList <ExpenseModel> > GetAll(int virtualAccountId)
        {
            var expenses = await _expenseRepository.GetAll(virtualAccountId);

            foreach (var expenseModel in expenses)
            {
                expenseModel.SalesDocuments = await _salesDocumentRepository.GetAll(expenseModel.Id);
            }
            return(expenses);
        }
Exemple #7
0
        public static bool IsExpenseExist(this IExpenseRepository expenseRepository, Guid id)
        {
            var expenseExist = expenseRepository.GetAll().Where(x => x.Id == id).Any();

            if (expenseExist)
            {
                return(true);
            }

            return(false);
        }
Exemple #8
0
        private void LoadExpense()
        {
            var expense = expenseRepository.GetAll(Store.ActiveMonth, Store.ActiveYear);

            lvwExpense.Items.Clear();

            foreach (var s in expense)
            {
                PopulateExpense(s);
            }
        }
Exemple #9
0
        public async Task <IActionResult> GetAllExpenses()
        {
            var AR = await _authorizationService.AuthorizeAsync(HttpContext.User, "Permission");

            if (!AR.Succeeded)
            {
                return(Unauthorized());
            }

            var expenses = await _repository.GetAll();

            List <ExpenseDto> expensesDto = new List <ExpenseDto>();

            expenses.ToList().ForEach(expense => expensesDto.Add(_mapper.Map <ExpenseDto>(expense)));
            return(Ok(expensesDto));
        }
Exemple #10
0
        public override IActionResult Get()
        {
            try
            {
                var data = _repo.GetAll <Expense>(x => x
                                                  .Include(x => x.Supplier)
                                                  .Include(x => x.Currency)
                                                  .Include(x => x.BranchOffice)
                                                  .Include(x => x.PaymentType)
                                                  .Where(y => y.Active == true));
                return(Ok(data));
            }

            catch (Exception ex)
            {
                return(Ok(new { status = -1, message = ex.Message }));
            }
        }
Exemple #11
0
        public IList <ExpenseObject> GetAllExpenseSheet()
        {
            try
            {
                List <ExpenseObject> exObjecttList = new List <ExpenseObject>();
                foreach (Expense source in (IEnumerable <Expense>)expenseRepo.GetAll())
                {
                    ExpenseObject exObject = _Mapper.Map <Expense, ExpenseObject>(source);
                    exObjecttList.Add(exObject);
                }

                return((IList <ExpenseObject>)exObjecttList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #12
0
        public ActionResult <List <ExpenseModel> > GetAll()
        {
            var expenses = _expenseRepository.GetAll().ToList() ?? new List <Expense>();
            var result   = new List <ExpenseModel>();

            expenses.ForEach(expense =>
            {
                result.Add(new ExpenseModel()
                {
                    Id              = expense.Id,
                    UserId          = expense.UserId,
                    Date            = expense.Date,
                    Amount          = expense.Amount,
                    Description     = expense.Description,
                    IsShared        = expense.IsShared,
                    SharedExpenseId = expense.SharedExpenseId
                });
            });
            return(result);
        }
Exemple #13
0
        public IEnumerable <Expense> GetAllExpenses(string userId)
        {
            var expenses = _expenseRepository.GetAll(userId);

            return(expenses);
        }
        public IEnumerable <Expense> GetExpenses()
        {
            IList <Expense> expenses = expenseRepository.GetAll().ToList();

            return(expenses);
        }
 public IEnumerable <Expense> GetAll()
 {
     return(_expenseRepository.GetAll());
 }
        public async Task <IActionResult> GetAll()
        {
            var result = await _expenseRepository.GetAll();

            return(Ok(result.OrderByDescending(x => x.Date)));
        }
 public IList <AccountsExpenseSet> GetExpensesList()
 {
     return(_expenseRepository.GetAll());
 }
Exemple #18
0
 public override List <Expense> GetAll()
 {
     return(_repository.GetAll().OrderByDescending(x => x.Modified).Take(10).ToList());
 }
        public ActionResult Get()
        {
            var expenses = _repo.GetAll();

            return(Ok(expenses));
        }
Exemple #20
0
        public async Task <IActionResult> GetAllExpenses(int idUser)
        {
            var expenses = await _expenseRepository.GetAll(idUser);

            return(Ok(expenses));
        }
Exemple #21
0
 public ActionResult <IEnumerable <Expense> > Get()
 {
     return(_expenseRepository.GetAll().ToArray());
 }
Exemple #22
0
 public async Task <ActionResult <IEnumerable <Expense> > > GetExpenses()
 {
     return(await _repository.GetAll());
 }