Exemplo n.º 1
0
        public async Task <PropertyFluctuations> GetPropertyFluctuations(string userId, DateTime dateFrom, DateTime dateTo)
        {
            if (dateFrom > dateTo || string.IsNullOrWhiteSpace(userId))
            {
                throw new InvalidParameterException();
            }
            try
            {
                var propertyFluctuations = new PropertyFluctuations();

                var listProperty = (await _unitOfWork.TransactionHistoryRepository.FindByAsync(i => i.User.Id == userId && i.TransactionDate.Date >= dateFrom.Date && i.TransactionDate.Date <= dateTo.Date, "User"))
                                   .OrderByDescending(i => i.Id)
                                   .GroupBy(i => i.TransactionDate.Date)
                                   .Select(g => new PropertyFluctuationItem()
                {
                    Date   = g.Key,
                    Amount = g.First().CurrentAccountAmount
                })
                                   .ToList();

                propertyFluctuations.ListProperty = listProperty.OrderBy(i => i.Date).ToList();

                return(propertyFluctuations);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PropertyFluctuations(string customerId, string dateFrom, string dateTo)
        {
            var model = new PropertyFluctuations();

            DateTime from = new DateTime();
            DateTime to   = new DateTime();

            if (string.IsNullOrWhiteSpace(dateFrom) || string.IsNullOrWhiteSpace(dateTo) || !DateTime.TryParseExact(dateFrom, "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out from) || !DateTime.TryParseExact(dateTo, "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out to) || from > to)
            {
                from = DateTime.Now.AddDays(-30).Date;
                to   = DateTime.Now.Date;
            }

            model = await _transactionHistoryService.GetPropertyFluctuations(customerId, from, to);

            return(Ok(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PropertyFluctuations(string dateFrom, string dateTo)
        {
            if (!_userService.IsSignedIn(User))
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            var currentUser = await _userService.GetCurrentUser();

            var model = new PropertyFluctuations();

            DateTime from = new DateTime();
            DateTime to   = new DateTime();

            if (string.IsNullOrWhiteSpace(dateFrom) || string.IsNullOrWhiteSpace(dateTo) || !DateTime.TryParseExact(dateFrom, "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out from) || !DateTime.TryParseExact(dateTo, "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out to) || from > to)
            {
                from = DateTime.Now.AddDays(-30).Date;
                to   = DateTime.Now.Date;
            }

            model = await _transactionHistoryService.GetPropertyFluctuations(currentUser.Id, from, to);

            return(Ok(model));
        }