Exemplo n.º 1
0
 public Event CreateEvent(Event eventData)
 {
     if (EventsValidator.ValidateEventData(eventData))
     {
         return(this._repository.CreateEvent(eventData));
     }
     else
     {
         throw new ApplicationException("Invalid Data");
     }
 }
Exemplo n.º 2
0
        public EventResponse CreateEvent(PostRequest <Event> postRequest)
        {
            var response = new EventResponse();

            if (postRequest.Payload != null)
            {
                var validator = new EventsValidator().Validate(postRequest.Payload).ToResponse();

                if (!validator.Result)
                {
                    return(ErrorResponse(validator));
                }

                try
                {
                    return(_eventsRepository.CreateEvent(postRequest));
                }
                catch (Exception ex)
                {
                    _logger.Error(ExceptionMessages.CreateEventException, ex);
                    response.Result = false;
                    response.Errors.Add(new ResponseError {
                        Name = "CreateEventException", Error = ExceptionMessages.CreateEventException
                    });
                    return(response);
                }
            }

            _logger.Information(ExceptionMessages.NullObject);
            response.Result = false;
            response.Errors.Add(new ResponseError()
            {
                Name = "NullObject", Error = ExceptionMessages.NullObject
            });
            return(response);
        }