public async Task <AmountDto> RetrieveAmountByClassAndFeeType(long classId, int feeType) { var nfeeType = (FeeType)feeType; var fee = new AmountDto(); if (classId < 1) { throw new ArgumentNullException(nameof(classId)); } if (feeType < 1) { throw new ArgumentNullException(nameof(feeType)); } var myFee = await _schoolhubDbContext.Amount.Where(s => s.ClassId == classId && s.FeeType == nfeeType).FirstOrDefaultAsync(); if (myFee != null) { fee.Id = myFee.Id; fee.ClassId = myFee.ClassId; fee.FeeAmount = myFee.FeeAmount; fee.FeeType = myFee.FeeType.GetDescription(); fee.Id = myFee.Id; fee.DateCreated = myFee.DateCreated; fee.UpdatedDate = myFee.UpdatedDate; return(fee); } return(null); }
public async Task <IActionResult> UpdateAmount([FromBody] AmountDto amountDto) { try { var amount = await _paymentAppServices.UpdateAmount(amountDto); if (amount == false) { return(BadRequest("Amount Update Failed")); } return(Ok(amount)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <bool> UpdateAmount(AmountDto amountDto) { if (amountDto == null) { throw new ArgumentNullException(nameof(amountDto)); } var amountUpdate = await _schoolhubDbContext.Amount.FirstOrDefaultAsync(s => s.Id == amountDto.Id); if (amountUpdate != null) { amountUpdate.Id = amountDto.Id; amountUpdate.FeeAmount = amountDto.FeeAmount; amountUpdate.UpdatedDate = DateTime.UtcNow; _schoolhubDbContext.Entry(amountUpdate).State = EntityState.Modified; await _schoolhubDbContext.SaveChangesAsync(); return(true); } return(false); }