public IActionResult CreateDatePlanning([FromBody] DatePlanningForCreationDto datePlanning)
        {
            try
            {
                if (datePlanning == null)
                {
                    _logger.LogError("date planning object sent from client is null.");
                    return(BadRequest("date planning object is null"));
                }

                if (!ModelState.IsValid)
                {
                    _logger.LogError("Invalid date planning object sent from client.");
                    return(BadRequest("Invalid model object"));
                }

                bool success = _datePlanningLogic.Create(datePlanning);

                return(Ok("date planning is created"));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error"));
            }
        }
Ejemplo n.º 2
0
        public bool Create(DatePlanningForCreationDto datePlanningForCreation)
        {
            try
            {
                var DataEntity = _mapper.Map <DatePlanning>(datePlanningForCreation);

                _repository.Create(DataEntity);
                _repository.Save();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside CreateArtist action: {ex.Message}");
                throw new Exception();
            }
        }