Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }