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); }
public HttpResponseMessage InsertStudentPayment([FromBody] StudentPaymentDto studentPaymentDto) { try { StudentPayment studentPayment = Converters.Convert(studentPaymentDto); if (!ValidateModel.IsValid(new List <object>() { studentPayment })) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidateModel.ModelsResults)); } StudentManager.InsertStudentPayment(studentPayment); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to insert the payment of student, {ex.Message}")); } }
public static StudentPayment Convert(StudentPaymentDto studentPaymentDto) { if (studentPaymentDto == null) { return(null); } return(new StudentPayment() { AttendanceSum = studentPaymentDto.AttendanceSum, DentalHealthSupportSum = studentPaymentDto.DentalHealthSupportSum, ExamsSum = studentPaymentDto.ExamsSum, FinancialSupportSum = studentPaymentDto.FinancialSupportSum, HealthSupportSum = studentPaymentDto.HealthSupportSum, LoansGivenSum = studentPaymentDto.LoansGivenSum, LoansReturnSum = studentPaymentDto.LoansReturnSum, Month = studentPaymentDto.Month, PaymentSum = studentPaymentDto.PaymentSum, StateBudgetSum = studentPaymentDto.StateBudgetSum, Year = studentPaymentDto.Year, Student = studentPaymentDto.Student }); }