Exemplo n.º 1
0
        public async Task <IActionResult> Get(long id)
        {
            var payType = await _payTypeRep.GetAsync(id);

            if (payType == null)
            {
                return(NotFound("Pay type not found !"));
            }
            var viewModel = AutoMapper.Mapper.Map <PayTypeViewModel>(payType);

            return(Ok(viewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetAll(long typeId)
        {
            var payType = await _payTypeRep.GetAsync(typeId);

            if (payType == null)
            {
                return(NotFound("Pay Not Found !"));
            }

            var payEntries = await _payEntryRepo.GetAllByTypeId(payType.Id).ToListAsync();

            var viewModels = AutoMapper.Mapper.Map <IEnumerable <PayEntryViewModel> >(payEntries);

            return(Ok(viewModels));
        }
Exemplo n.º 3
0
        public async Task <long> GetNextNumberAsync(long payTypeNumber)
        {
            var payType = await _payTypeRepo.GetAsync(payTypeNumber);

            if (payType != null)
            {
                var payTypeId = payType.Id;
                var result    = _payEntryRepo.GetAll().Where(p => p.PayTypeId == payTypeId);
                var count     = result.Count();
                if (count == 0)
                {
                    return(1);
                }
                var maxNumber = result.Max(e => e.Number);
                return(maxNumber + 1);
            }
            else
            {
                return(1);
            }
        }