예제 #1
0
 public EventResponse GetEvent(EventIdRequest idRequest)
 {
     using (var db = new EventSourceDbContext(_dbContext))
     {
         return(new EventResponse
         {
             Event = db.Events.FirstOrDefault(e => e.Id == idRequest.Id)
         });
     }
 }
예제 #2
0
        public Response DeleteEvent(EventIdRequest idRequest)
        {
            using (var db = new EventSourceDbContext(_dbContext))
            {
                var @event = db.Events.Find(idRequest.Id);

                db.Events.Remove(@event);
                db.SaveChanges();

                return(new Response());
            }
        }
예제 #3
0
        /// <summary>
        /// Returns an individual Event.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public Event GetEvent(EventIdRequest request)
        {
            Event @event   = null;
            var   response = GetAsync($"events/{request.Id}").Result;

            if (response.IsSuccessStatusCode)
            {
                var result = response.Content.ReadAsStringAsync().Result;
                @event = JsonConvert.DeserializeObject <Event>(result);
            }

            return(@event);
        }
        public static Event GetEvent([ActivityTrigger] DurableActivityContext inputs)
        {
            (int EventId, string Path)input = inputs.GetInput <(int, string)>();

            _client = InitClient(input.Path);

            var request = new EventIdRequest()
            {
                Id = input.EventId
            };

            return(_client.EventsClient.GetEvent(request));
        }
예제 #5
0
        public static Event GetEvent([ActivityTrigger] int eventId)
        {
            var request = new EventIdRequest()
            {
                Id = eventId
            };

            try
            {
                log.Information("Calling GetEvent function.");
                return(client.EventsClient.GetEvent(request));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                return(null);
            }
        }
예제 #6
0
        public EventResponse GetEvent(EventIdRequest idRequest)
        {
            var validator = new Response();
            var response  = new EventResponse();

            try
            {
                validator = new EventIdRequestValidator(_eventsRepository).Validate(idRequest).ToResponse();
            }
            catch (Exception ex)
            {
                _logger.Error(ExceptionMessages.GetEventException, ex);
                response.Result = false;
                response.Errors.Add(new ResponseError {
                    Name = "GetEventException", Error = ExceptionMessages.GetEventException
                });
                return(response);
            }

            if (!validator.Result)
            {
                return new EventResponse()
                       {
                           Errors = validator.Errors
                       }
            }
            ;

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

            return(response);
        }
예제 #7
0
        public IActionResult GetEvent(int id)
        {
            var idRequest = new EventIdRequest()
            {
                Id = id
            };

            _logger.Information($"Getting Event with Id: {idRequest.Id}.");

            var response = _eventsService.GetEvent(idRequest);

            if (!response.Result)
            {
                return(BadRequest(response.Errors));
            }

            if (response.Event == null)
            {
                return(NotFound("Event Not Found."));
            }

            return(Ok(response.Event));
        }
예제 #8
0
        public IActionResult DeleteEvent(int id)
        {
            var idRequest = new EventIdRequest()
            {
                Id = id
            };

            _logger.Information($"Deleting Event with id: {idRequest.Id}");

            var response = _eventsService.DeleteEvent(idRequest);

            if (!response.Result)
            {
                return(BadRequest(response.Errors));
            }

            if (response.Errors.Count > 0)
            {
                return(NotFound(response.Errors));
            }

            return(Ok());
        }
예제 #9
0
        /// <summary>
        /// Deletes an individual Event
        /// </summary>
        /// <param name="request"></param>
        /// <returns>
        /// Returns true or false
        /// </returns>
        public bool DeleteEvent(EventIdRequest request)
        {
            var response = DeleteAsync($"events/{request.Id}").Result;

            return(response.IsSuccessStatusCode);
        }