Example #1
0
        public async Task <IActionResult> CreateAmount([FromBody] CreateAmountDto createAmountDto)
        {
            try
            {
                var amount = await _paymentAppServices.CreateAmount(createAmountDto);

                if (amount < 1)
                {
                    return(BadRequest("Amount Creation Failed"));
                }
                return(Ok(amount));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #2
0
        public async Task <int> CreateAmount(CreateAmountDto createAmountDto)
        {
            Amount amount;

            if (createAmountDto == null)
            {
                throw new ArgumentNullException(nameof(createAmountDto));
            }

            amount = new Amount
            {
                ClassId     = createAmountDto.ClassId,
                FeeAmount   = createAmountDto.FeeAmount,
                FeeType     = createAmountDto.FeeType,
                DateCreated = DateTime.UtcNow,
            };
            await _schoolhubDbContext.Amount.AddAsync(amount);

            await _schoolhubDbContext.SaveChangesAsync();

            return(amount.Id);
        }