public async Task <EVoucherDetail_EVoucherDTO> Get([FromBody] EVoucherDetail_EVoucherDTO EVoucherDetail_EVoucherDTO) { if (!ModelState.IsValid) { throw new MessageException(ModelState); } EVoucher EVoucher = await EVoucherService.Get(EVoucherDetail_EVoucherDTO.Id); return(new EVoucherDetail_EVoucherDTO(EVoucher)); }
public EVoucher ConvertDTOToEntity(EVoucherDetail_EVoucherDTO EVoucherDetail_EVoucherDTO) { EVoucher EVoucher = new EVoucher(); EVoucher.Id = EVoucherDetail_EVoucherDTO.Id; EVoucher.CustomerId = EVoucherDetail_EVoucherDTO.CustomerId; EVoucher.ProductId = EVoucherDetail_EVoucherDTO.ProductId; EVoucher.Name = EVoucherDetail_EVoucherDTO.Name; EVoucher.Start = EVoucherDetail_EVoucherDTO.Start; EVoucher.End = EVoucherDetail_EVoucherDTO.End; EVoucher.Quantity = EVoucherDetail_EVoucherDTO.Quantity; return(EVoucher); }
public async Task <ActionResult <EVoucherDetail_EVoucherDTO> > Update([FromBody] EVoucherDetail_EVoucherDTO EVoucherDetail_EVoucherDTO) { if (!ModelState.IsValid) { throw new MessageException(ModelState); } EVoucher EVoucher = ConvertDTOToEntity(EVoucherDetail_EVoucherDTO); EVoucher = await EVoucherService.Update(EVoucher); EVoucherDetail_EVoucherDTO = new EVoucherDetail_EVoucherDTO(EVoucher); if (EVoucher.IsValidated) { return(EVoucherDetail_EVoucherDTO); } else { return(BadRequest(EVoucherDetail_EVoucherDTO)); } }