public async Task <IReadOnlyCollection <ITelegramResponse> > Handle(FullEventInfoCommand request, CancellationToken cancellationToken) { var eventInfo = await _repository.GetEvent(request.EventId, cancellationToken); var inlineKeyboardButton = InlineKeyboardButton.WithCallbackData("Hide", $"{CommandMessages.CallbackHide}:{eventInfo.Id}"); return(new List <ITelegramResponse> { new EditKeyboardTelegramResponse(new InlineKeyboardMarkup(inlineKeyboardButton), FormatCaption(eventInfo)) }); }
// GET: Events/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Event @event = repo.GetEvent(id); if (@event == null) { return(HttpNotFound()); } return(View(@event)); }
public async Task <ServiceStatus> UpdateEvent(int id, EventDto updatedEvent) { var eventToUpdate = await _eventsRepository.GetEvent(id); if (eventToUpdate == null) { return(ServiceStatus.NotFound); } eventToUpdate = _mapper.Map <EventDto, Event>(updatedEvent); await _eventsRepository.UpdateEvent(id, eventToUpdate); return(ServiceStatus.Success); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log) { try { log.Info("C# HTTP trigger function processed a request."); // parse query parameter string eventId = req.GetQueryNameValuePairs() .FirstOrDefault(q => string.Compare(q.Key, "eventId", true) == 0) .Value; IEventsRepository eventsRepository = RepositoryFactory.GetEventsRepository(); if (!string.IsNullOrEmpty(eventId)) { // Get of a specific event var guid = Guid.Parse(eventId); var @event = eventsRepository.GetEvent(guid); return(@event != null?req.CreateResponse(HttpStatusCode.Found, @event) : req.CreateErrorResponse(HttpStatusCode.NotFound, "Event not found")); } // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); List <IEvent> events = eventsRepository.GetEvents((string)data?.category, (IAddress)data?.location, (DateTime?)data?.fromDate, (DateTime?)data?.toDate); return(req.CreateResponse(HttpStatusCode.OK, events)); } catch (Exception ex) { log.Error("Error", ex, "GetEvents.cs"); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public ActionResult FindSeats(string tenant, int eventId) { if (eventId != 0) { SetTenantConfig(tenant); var eventDetails = _eventsRepository.GetEvent(eventId, _connectionString, Startup.TenantConfig.TenantId); if (eventDetails != null) { var eventSections = _eventSectionRepository.GetEventSections(eventId, _connectionString, Startup.TenantConfig.TenantId); var seatSectionIds = eventSections.Select(i => i.SectionId).ToList(); var seatSections = _sectionRepository.GetSections(seatSectionIds, _connectionString, Startup.TenantConfig.TenantId); if (seatSections != null) { var ticketsSold = _ticketRepository.GetTicketsSold(seatSections[0].SectionId, eventId, _connectionString, Startup.TenantConfig.TenantId); FindSeatViewModel viewModel = new FindSeatViewModel { EventDetails = eventDetails, SeatSections = seatSections, SeatsAvailable = (seatSections[0].SeatRows * seatSections[0].SeatsPerRow) - ticketsSold }; return(View(viewModel)); } } } return(RedirectToAction("Index", "Events", new { tenant = Startup.TenantConfig.TenantName })); }
public new async Task <IActionResult> View(string id) { var ev = eventRepo.GetEvent(id); if (ev == null) { throw new ArgumentException(); } var device = deviceRepo.GetDevice(ev.DeviceId); if (device == null) { throw new ArgumentException(); } if (!string.IsNullOrEmpty(ev.FilterName)) { bool isInRules = await TryFindInRules(device, ev); if (isInRules) { return(RedirectToAction("View", "Rules", new { id = device.Id, name = ev.FilterName })); } } var data = eventRepo.GetEventsForTheLast24Hours(device.Id, ev.FilterName); var last24Hours = GoogleChartHelpers.To24HourArray(data); ViewData["Last24Hours"] = GoogleChartHelpers.ToGoogleChartString(last24Hours, "Time", "Count"); return(View(ev)); }
private bool CheckIfEventExists(int id) { var eventResponse = _eventsRepository.GetEvent(new EventIdRequest { Id = id }); return(eventResponse.Result && eventResponse.Event != null); }
public void GetEventTest() { var result = _eventsRepository.GetEvent(1, _connectionString, _tenantId); Assert.IsNotNull(result); Assert.AreEqual(1, result.EventId); Assert.AreEqual("Event 1", result.EventName); Assert.AreEqual("Event 1 Subtitle", result.SubTitle); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, TraceWriter log) { try { log.Info("C# HTTP trigger function processed a request."); // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); if (string.IsNullOrEmpty((string)data?.eventId)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Missing Event id.")); } IEventsRepository eventsRepository = RepositoryFactory.GetEventsRepository(); var eventToSignup = eventsRepository.GetEvent((Guid)data.eventId); if (eventToSignup == null) { return(req.CreateErrorResponse(HttpStatusCode.NotFound, "Event not found.")); } var participant = new Participant() { Name = data?.name, Email = data?.email, PhoneNumber = data?.phonenumber, Address = new Address() { City = data?.address?.city, Country = data?.address?.country, PostalCode = data?.address?.postalCode, State = data?.address?.state } }; if (!participant.IsValid()) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid signup information.")); } // Check if participant is already signed up. if (eventToSignup.IsParticipantSignedUp(participant.Email)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "You are already signed up to this event.")); } eventToSignup.AddParticipant(participant); return(req.CreateResponse(HttpStatusCode.Accepted)); } catch (Exception ex) { log.Error("Error", ex, "Signup.cs"); return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
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); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = null)] HttpRequestMessage req, TraceWriter log) { try { log.Info("C# HTTP trigger function processed a request."); // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); // Validate data if (string.IsNullOrEmpty(data?.eventId) || string.IsNullOrEmpty(data?.email)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "Missing parameters.")); } IEventsRepository eventsRepository = RepositoryFactory.GetEventsRepository(); // check if person is actually signed up. var @event = eventsRepository.GetEvent((Guid)data?.eventId); if (@event == null || [email protected]((string)data?.email)) { return(req.CreateErrorResponse(HttpStatusCode.NotFound, "You are not signed up for this event.")); } // Proceed to remove participant from event if (@event.RemoveParticipant((string)data?.email)) { // Successfully cancelled participation return(req.CreateResponse(HttpStatusCode.Accepted)); } return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, "Failed to cancel participation.")); } catch (Exception ex) { return(req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public async Task <JsonResult> AddOrUpdateEvents(Events events) { var files = HttpContext.Request.Form.Files; IFormFile file; try { if (events != null) { //Yeni Event oluşturma if (events.Id == 0) { Events newEvent = new Events(); newEvent.IconName = events.IconName; newEvent.ShowOnPage = events.ShowOnPage; newEvent.Title = events.Title; newEvent.PopupState = events.PopupState; newEvent.Content = events.Content; //image save if (files != null) { file = files[0]; if (file != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } newEvent.PhotoPath = file.FileName; eventsRepository.AddEvent(newEvent); } else { eventsRepository.AddEvent(newEvent); } } } else { var oldEvent = eventsRepository.GetEvent(events.Id); oldEvent.IconName = events.IconName; oldEvent.PopupState = events.PopupState; oldEvent.ShowOnPage = events.ShowOnPage; oldEvent.Title = events.Title; oldEvent.Content = events.Content; if (files.Count > 0) { file = files[0]; if (file != null) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } var oldEventPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img\\Events", oldEvent.PhotoPath); System.IO.File.Delete(oldEventPath); oldEvent.PhotoPath = file.FileName; eventsRepository.UpdateEvent(oldEvent); } else { eventsRepository.UpdateEvent(oldEvent); } } else { eventsRepository.UpdateEvent(oldEvent); } } return(Json(1)); } return(Json(0)); } catch (Exception e) { return(Json(-1)); } }
public Task <Event> Get(long id) { return(_eventsRepository.GetEvent(id)); }