public static void UpdatePaymentFromDto(Payment paymentToUpdate, PaymentForCreationDTO paymentWithUpdatedValues) { paymentToUpdate.EmployeeId = paymentWithUpdatedValues.EmployeeId; paymentToUpdate.HourlyRate = paymentWithUpdatedValues.HourlyRate; paymentToUpdate.ContractType = paymentWithUpdatedValues.contractType; paymentToUpdate.JobTimePortion = paymentWithUpdatedValues.jobTimePortion; }
public static Payment GetPaymentEntity(PaymentForCreationDTO paymentDto) { return(new Payment() { EmployeeId = paymentDto.EmployeeId, HourlyRate = paymentDto.HourlyRate, ContractType = paymentDto.contractType, JobTimePortion = paymentDto.jobTimePortion }); }
public IActionResult PostPayment([FromBody] PaymentForCreationDTO paymentFromRequest) { if (paymentFromRequest == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest()); } _repo.AddPayment(ModelsMapping.GetPaymentEntity(paymentFromRequest)); return(Ok()); }
public IActionResult PutPayment([FromBody] PaymentForCreationDTO paymentFromRequest, int paymentId) { if (paymentFromRequest == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest()); } var payment = _repo.GetPayment(paymentId); ValuesUpdater.UpdatePaymentFromDto(payment, paymentFromRequest); _repo.SaveChanges(); return(Ok()); }