public async Task <IActionResult> Edit(long id, [Bind("Id,PaymentDate,StudentId,FeeId,PaymentTypeId,Fine,Discount,PaidAmount,Remarks")] StudentPayments studentPayments) { if (id != studentPayments.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(studentPayments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentPaymentsExists(studentPayments.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FeeId"] = new SelectList(_context.Fees, "Id", "Id", studentPayments.FeeId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentTypes, "Id", "Id", studentPayments.PaymentTypeId); return(View(studentPayments)); }
public HttpResponseMessage GetPayments([FromUri] int?from = null, [FromUri] int?amount = null) { try { StudentPayments studentPayments = StudentPaymentManager.GetPayments(from, amount); List <StudentPaymentDto> studentPaymentsDto = Converters.Convert(studentPayments); return(Request.CreateResponse(HttpStatusCode.OK, studentPaymentsDto)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to load payment")); } }
public static StudentPayments TableToStudentPayments(DataTable table) { if (table == null) { return(null); } StudentPayments studentPayments = new StudentPayments(); var studentPaymentList = table.AsEnumerable().GroupBy(row => DataRowHelper.GetValue <int>(row, Tables.StudentPayment.Id.Name), (key, group) => RowToStudentPayment(group)); studentPayments.AddRange(studentPaymentList.ToList()); return(studentPayments); }
public static StudentPayments GetPayments(int?from, int?amount) { try { StudentPayments payments = StudentPaymentDataManager.GetAllPayments(from, amount); return(payments); } catch (Exception ex) { _logger.Debug($"Failed to load payments.", ex); throw; } }
public async Task <IActionResult> Create([Bind("Id,PaymentDate,StudentId,FeeId,PaymentTypeId,Fine,Discount,PaidAmount,Remarks")] StudentPayments studentPayments) { if (ModelState.IsValid) { _context.Add(studentPayments); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FeeId"] = new SelectList(_context.Fees, "Id", "Id", studentPayments.FeeId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentTypes, "Id", "Id", studentPayments.PaymentTypeId); return(View(studentPayments)); }
public static List <StudentPaymentDto> Convert(StudentPayments studentPayments) { if (studentPayments != null) { List <StudentPaymentDto> studentPaymentsDto = new List <StudentPaymentDto>(); foreach (StudentPayment studentPayment in studentPayments) { StudentPaymentDto item = ConvertToDto(studentPayment); studentPaymentsDto.Add(item); } return(studentPaymentsDto); } return(null); }