public async Task <IHttpActionResult> AddExceptionLogger([FromBody] ExceptionLoggerDTO exceptionLoggerModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var ExceptionLoggerId = await ExceptionLoggerService.AddExceptionAsync(exceptionLoggerModel); if (ExceptionLoggerId != 0) { return(Ok(ExceptionLoggerId)); } else { return(NotFound()); } }
public async Task <int> AddExceptionAsync(ExceptionLoggerDTO modelDTO) { try { using (var unitOfWork = unitOfWorkFactory.Create()) { ExceptionLogger model = _Mapper_ToModel.Map <ExceptionLoggerDTO, ExceptionLogger>(modelDTO); unitOfWork.ExceptionLoggerRepository.Add(model); await unitOfWork.SaveChangesAsync(); return(model.Id); } } catch (Exception ex) { LogException(ex); throw ex; } }