public WarningResponse Create(WarningRequest warningRequest) { var warning = Mapper.Map <WarningMessage>(warningRequest); var result = _warningMessageService.Create(warning, out var isSaved); if (!isSaved) { throw new InternalServerErrorException(CommonConstant.Error.InternalServerError); } var warningResponse = Mapper.Map <WarningResponse>(result); return(warningResponse); }
public CreateResponse Create(WarningRequest request) { try { var warning = TypeAdapter.Adapt <Warning>(request); _warningValidator.ValidateAndThrowException(warning, "Base,Create"); _warningRepository.Add(warning); return(new CreateResponse(warning.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public SuccessResponse Update(WarningRequest request) { try { var currentWarning = _warningRepository.FindBy(request.Id); currentWarning.ThrowExceptionIfRecordIsNull(); var warningToCopy = TypeAdapter.Adapt <Warning>(request); TypeAdapter.Adapt(warningToCopy, currentWarning); _warningValidator.ValidateAndThrowException(currentWarning, "Base,Update"); _warningRepository.Update(currentWarning); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }
public WarningResponse Create([FromBody] WarningRequest warningRequest) { return(_warningMessageService.Create(warningRequest)); }
public SuccessResponse Put(WarningRequest request) { return(_warningService.Update(request)); }
public CreateResponse Post(WarningRequest request) { return(_warningService.Create(request)); }