public async Task <IActionResult> GetTransactions(int wbsId, [FromQuery] TransParams transParams)
        {
            transParams.WBSId = wbsId;
            var TransactionsFromRepo = await _repo.GetTransactions(transParams);

            Response.AddPagination(TransactionsFromRepo.CurrentPage, TransactionsFromRepo.PageSize,
                                   TransactionsFromRepo.TotalCount, TransactionsFromRepo.TotalPages);

            return(Ok(TransactionsFromRepo));
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <Transaction> > GetTransReport(TransParams transParams)
        {
            var transaction = _Context.transactions.Include(u => u.Created).Include(c => c.Category).Include(a => a.Activity)
                              .OrderBy(t => t.CategoryId).ThenByDescending(t => t.Id).AsQueryable();

            if (transParams.activity > 0)
            {
                transaction = transaction.Where(t => t.ActivityId == transParams.activity);
            }

            if (!string.IsNullOrEmpty(transParams.Active))
            {
                int active = 0;
                if (int.TryParse(transParams.Active, out active))
                {
                    transaction = transaction.Where(t => t.Active == active);
                }
            }

            DateTime?dtFr = null;
            DateTime?dtTo = null;

            if (!string.IsNullOrEmpty(transParams.dateFr))
            {
                dtFr = CommonMethod.stringToDate(transParams.dateFr);
            }

            if (!string.IsNullOrEmpty(transParams.dateTo))
            {
                dtTo = CommonMethod.stringToDate(transParams.dateTo);
            }

            if (dtFr != null)
            {
                if (dtTo != null)
                {
                    transaction = transaction.Where(t => t.TransactionDate >= dtFr && t.TransactionDate <= dtTo);
                }
                else
                {
                    transaction = transaction.Where(t => t.TransactionDate >= dtFr);
                }
            }
            else if (dtTo != null)
            {
                transaction = transaction.Where(t => t.TransactionDate <= dtTo);
            }

            if (!string.IsNullOrEmpty(transParams.trType))
            {
                transaction = transaction.Where(t => t.TransactionType == transParams.trType);
            }

            return(await transaction.ToListAsync());
        }
        /*public MapEventData[] GetMapEventData()
         * {
         *  int index = SceneManager.GetActiveScene().buildIndex;
         *  return MapEvents.Where(val => val.SceneNumber == index).ToArray();
         * }*/
        public TransParam[] GetTransitionParams(MapEventData mapEvent, Vector2Int pos)
        {
            var param = TransParams.SingleOrDefault(p => p.CurrentScene == mapEvent.SceneNumber);
            var list  = new List <TransParam>();

            foreach (var e in mapEvent[pos])
            {
                if (e.Event == MapEventData.Event.Transition || e.Event == MapEventData.Event.Transition_Action)
                {
                    list.AddRange(param.GetParameters(e.NextScene));
                }
            }
            return(list.ToArray());
        }
        public async Task <IHttpActionResult> Gettransactions([FromUri] TransParams transParams)
        {
            var trans = await _Repo.GetTransaction(transParams);

            var result = _Mapper.Map <IEnumerable <TransactionDto> >(trans);

            var paginationHeader   = new PaginationHeader(trans.CurrentPage, trans.PageSize, trans.TotalCount, trans.TotalPages);
            var camelCaseFormatter = new JsonSerializerSettings();

            camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver();
            Request.Properties["Pagination"]    = JsonConvert.SerializeObject(paginationHeader, camelCaseFormatter);

            return(Ok(_Mapper.Map <IEnumerable <TransactionDto> >(trans)));
        }
Ejemplo n.º 5
0
        public async Task <PagedList <Transaction> > GetTransaction(TransParams transParams)
        {
            var transaction = _Context.transactions.Include(u => u.Created).Include(c => c.Category).Include(a => a.Activity)
                              .OrderByDescending(t => t.Id).AsQueryable();

            if (transParams.activity > 0)
            {
                transaction = transaction.Where(t => t.ActivityId == transParams.activity);
            }

            DateTime?dtFr = null;
            DateTime?dtTo = null;

            if (!string.IsNullOrEmpty(transParams.dateFr))
            {
                dtFr = CommonMethod.stringToDate(transParams.dateFr);
            }

            if (!string.IsNullOrEmpty(transParams.dateTo))
            {
                dtTo = CommonMethod.stringToDate(transParams.dateTo);
            }

            if (dtFr != null)
            {
                if (dtTo != null)
                {
                    transaction = transaction.Where(t => t.TransactionDate >= dtFr && t.TransactionDate <= dtTo);
                }
                else
                {
                    transaction = transaction.Where(t => t.TransactionDate >= dtFr);
                }
            }
            else if (dtTo != null)
            {
                transaction = transaction.Where(t => t.TransactionDate <= dtTo);
            }

            if (!string.IsNullOrEmpty(transParams.trType))
            {
                transaction = transaction.Where(t => t.TransactionType == transParams.trType);
            }

            return(await PagedList <Transaction> .CreateAsync(transaction, transParams.PageNumber, transParams.PageSize));
        }
Ejemplo n.º 6
0
        public async Task <PagedList <TransactionsForListDto> > GetTransactions(TransParams transParams)
        {
            var res = (from transaction in _context.ProjectTransactions where (transaction.IsDeleted == false && transaction.WBSId == transParams.WBSId) orderby transaction.TransactionDate descending select new TransactionsForListDto {
                Id = transaction.Id,
                TransactionTypeId = transaction.TransactionTypeId,
                TransactionDate = transaction.TransactionDate,
                Amount = transaction.Amount,
                CurrencyId = transaction.CurrencyId,
                ExchangeRate = transaction.ExchangeRate,
                ProvinceId = transaction.ProvinceId,
                ProvinceName = transaction.Province.ProvinceName,
                CurrencyName = transaction.Currency.CurrencyName,
                Description = transaction.Description,
                WBSId = transaction.WBSId,
                WBSName = transaction.WBS.WBSName,
                TransactionType = transaction.TransactionType.TransactionTypeName
            });

            if (transParams.TransactionTypeId != null)
            {
                res = res.Where(c => c.TransactionTypeId == transParams.TransactionTypeId);
            }
            if (!string.IsNullOrWhiteSpace(transParams.FromDate))
            {
                var      strDateTime = transParams.FromDate.Substring(4, 20);
                DateTime fromDate    = DateTime.Parse(strDateTime);
                res = res.Where(c => c.TransactionDate >= fromDate);
            }
            if (!string.IsNullOrWhiteSpace(transParams.ToDate))
            {
                var      strDateTime = transParams.ToDate.Substring(4, 20);
                DateTime toDate      = DateTime.Parse(strDateTime);
                res = res.Where(c => c.TransactionDate <= toDate);
            }
            if (transParams.ProvinceId != null)
            {
                res = res.Where(c => c.ProvinceId == transParams.ProvinceId);
            }
            return(await PagedList <TransactionsForListDto> .CreateAsync(res, transParams.PageNumber, transParams.PageSize));
        }
        public async Task <IHttpActionResult> GetTransReport([FromUri] TransParams transParams)
        {
            var trans = await _Repo.GetTransReport(transParams);

            return(Ok(_Mapper.Map <IEnumerable <TransactionDto> >(trans)));
        }