[ProducesResponseType(404)] // NotFound public IActionResult NewEventType([FromBody] EventTypeDetails newType) { try { var record = _mapper.Map <EventType>(newType); _unitOFWork.EventTypes.Insert(record); _unitOFWork.Commit(); return(StatusCode(201, new NewRecordResponse { id = record.TypeId })); } catch (Exception e) { _logger.LogError(e, "Internal Server Error"); return(StatusCode(500)); } }
[ProducesResponseType(404)] // NotFound public IActionResult UpdateEventType(int id, [FromBody] EventTypeDetails eventType) { try { var evType = _mapper.Map <EventType>(eventType); evType.TypeId = id; _unitOFWork.EventTypes.Update(id, evType); _unitOFWork.Commit(); return(StatusCode(201)); } catch (Exception e) { if (e.GetType() == typeof(System.ArgumentException)) { _logger.LogError(e, "Argument Error"); return(StatusCode(400, new ProblemDetails { Title = "Argument Error", Detail = e.Message })); } _logger.LogError(e, "Internal Server Error"); return(StatusCode(500)); } }