public IActionResult CreateEventDate([FromBody] EventDateForCreationDto eventDate) { try { if (eventDate == null) { _logger.LogError("EventDate object sent from client is null."); return(BadRequest("EventDate object is null")); } if (!ModelState.IsValid) { _logger.LogError("Invalid EventDate object sent from client."); return(BadRequest("Invalid model object")); } bool success = _eventDateLogic.Create(eventDate); return(Ok("EventDate is created")); //return CreatedAtRoute("CategoryById", new { id = createdEntity.id }, createdEntity); } catch (Exception ex) { return(StatusCode(500, "Internal server error")); } }
public bool Create(EventDateForCreationDto eventDateForCreation) { try { EventDate DataEntity = _mapper.Map <EventDate>(eventDateForCreation); _repository.Create(DataEntity); _repository.Save(); return(true); } catch (Exception ex) { _logger.LogError($"Something went wrong inside CreateEventDate action: {ex.Message}"); throw new Exception(); } }