public static object fetchEvents(int pageNumber, string tab) { return(new ThunkAction <AppState>((dispatcher, getState) => { return EventApi.FetchEvents(pageNumber, tab, "offline") .Then(eventsResponse => { dispatcher.dispatch(new UserMapAction { userMap = eventsResponse.userMap }); dispatcher.dispatch(new PlaceMapAction { placeMap = eventsResponse.placeMap }); dispatcher.dispatch(new FetchEventsSuccessAction { eventsResponse = eventsResponse, tab = tab, pageNumber = pageNumber } ); }) .Catch(error => { dispatcher.dispatch(new FetchEventsFailureAction() { tab = tab, pageNumber = pageNumber }); Debug.Log(error); }); })); }
public static async Task Main(string[] args) { Console.WriteLine("Service started..."); Dapper.SqlMapper.AddTypeHandler(typeof(MessageNumber), new MessageNumberEventHandler()); var httpClientWrapper = new HttpClientWrapper(); var eventConverter = new ShoppingCartEventConverter(); var eventApi = new EventApi( host: "http://localhost:9050", httpClientWrapper: httpClientWrapper, eventConverter: eventConverter, batchSize: 10 ); var eventMonitor = new EventMonitor(eventApi: eventApi, eventTrackingRepository: new EventTrackingRepository()); var consoleEventHandler = new ConsoleEventHandler(); var itemTypeReadModelHandler = new ItemTypeReadModelHandler(new ItemTypeReadRepository(Database.ConnectionString)); eventMonitor.Subscribe <ItemTypeCreatedEvent>("itemType", itemTypeReadModelHandler, consoleEventHandler); var itemReadModelHandler = new ItemReadModelHandler(new ItemReadRepository(Database.ConnectionString)); eventMonitor.Subscribe <ItemCreatedEvent>("item", itemReadModelHandler, consoleEventHandler); eventMonitor.Subscribe <ItemAmountDiscountSetEvent>("item", itemReadModelHandler, consoleEventHandler); eventMonitor.Subscribe <ItemPercentageDiscountSetEvent>("item", itemReadModelHandler, consoleEventHandler); var couponReadModelHandler = new CouponReadModelHandler(new CouponReadRepository(Database.ConnectionString)); eventMonitor.Subscribe <CouponCreatedEvent>("coupon", couponReadModelHandler, consoleEventHandler); var cancellationTokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = cancellationTokenSource.Token; var task = Task.Run(async() => { while (true) { Console.WriteLine("Polling..."); await PollEvents(eventMonitor); await Task.Delay(1000, cancellationToken); if (cancellationToken.IsCancellationRequested) { // Clean up here, then... cancellationToken.ThrowIfCancellationRequested(); } } }, cancellationTokenSource.Token); Console.WriteLine("Press any key to quit..."); while (!Console.KeyAvailable) { await Task.Delay(1000); } Console.ReadKey(true); cancellationTokenSource.Cancel(); }
private static List <Program.Transfer> GetAdvScript(TalkScene scene, int topicno, int personality, bool isnpc) { // todo variations for rejectng, already pregnant (don't need them anymore) var list = EventApi.CreateNewEvent(); list.Add(Program.Transfer.Text(EventApi.Narrator, "I activated these earlier with my cum, I wonder if I should try giving this pack to her as a gift...")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Hmm? What's wrong?")); list.Add(Program.Transfer.Text(EventApi.Player, "Umm, actually I bought you a gift, but it might be a bit weird.")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Haha, don't worry you're plenty weird anyways. So, what's the gift?")); list.Add(Program.Transfer.Text(EventApi.Narrator, "I take out the box and offer it to her. There was a replacement seal included in the box so it looks unopened.")); list.Add(Program.Transfer.Text(EventApi.Player, "Here.")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Huh? Are those..?")); list.Add(Program.Transfer.Text(EventApi.Narrator, "She stares at the box in silence for a good while.")); list.Add(Program.Transfer.Text(EventApi.Player, "It's too weird after all. Sorry, can you forget about-")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Ah, no it's fine! I was just surprised since I didn't know guys knew about these things.")); list.Add(Program.Transfer.Text(EventApi.Player, "Yeah, I guess that's true.")); list.Add(Program.Transfer.Text(EventApi.Heroine, "I use similar looking ones so they should be fine, I'll take them. You won't have any use for them anyways, haha.")); list.Add(Program.Transfer.Text(EventApi.Player, "Really? Here you go then.")); list.Add(Program.Transfer.Text(EventApi.Narrator, "She carefully takes the box from my hand.")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Thanks!")); list.Add(Program.Transfer.Text(EventApi.Heroine, "Ahh, just so you know, you shouldn't give these to other girls! You got lucky with me, but others might think it's sexual harassment and kick you in the groin.")); list.Add(Program.Transfer.Text(EventApi.Player, "I-I'll keep that in mind.")); list.Add(Program.Transfer.VAR("System.Boolean", "Success", "true")); list.Add(Program.Transfer.VAR("System.Int32", "FavorChange", "20")); list.Add(Program.Transfer.VAR("System.Int32", "LewdChange", "10")); list.Add(Program.Transfer.Close()); return(list); }
/// <summary> /// Initializes a new instance of the <see cref="FacebookApi"/> class. /// </summary> /// <param name="config">The config.</param> public FacebookApi(IFacebookConfig config) { Config = config; Event = new EventApi(this); Auth = new AutenticationApi(this); }
public void OneCreateWithConfig() { configuration = GetClientConfig(); EventApi eventApitest = new EventApi(configuration); Assert.NotNull(eventApitest.Configuration); }
public void RetrieveEvent_IssuedWithKnownId_ReturnsEvent(WireDataFormat format) { var client = TestContext.CreateClientNoCredentials(format); var eventApi = new EventApi(client.HttpChannel); eventApi.Retrieve(479546); // VLM 2011 on local dev }
public void RetrievePages_IssuedWithKnownIdAndPage2_ReturnsPages(WireDataFormat format) { var client = TestContext.CreateClientNoCredentials(format); var eventApi = new EventApi(client.HttpChannel); eventApi.RetrievePages(479546, 20, 2); // VLM 2011 on local dev }
public async Task CallsFirstBatchOfEvents_ResponseHasOneEvent() { var httpClientWrapper = new FakeEventHttpClientWrapper( resourceName: "test-message-type", events: new List <EventInfo> { new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0") } } }); var apiHelper = new EventApi("http://localhost/", httpClientWrapper, TestResourceEventConverter.Instance, 10); var result = await apiHelper.GetEventsAfterAsync("resource", lastMessageNumber : MessageNumber.NotSet); Assert.Equal(1, httpClientWrapper.MessagesSent.Count); Assert.Equal("/events/resource/0-9", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath); Assert.NotNull(result); Assert.IsType <TestResourceCreatedEvent>(result[0]); Assert.Equal(new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0"), ((TestResourceCreatedEvent)result[0]).Id); }
// GET: Event/Delete/5 public ActionResult Delete(int id) { var api = new EventApi(_apiSettings.ApiBaseUrl); var model = api.DeleteEvent(id); return(RedirectToAction(nameof(Index))); }
public static object fetchEventDetail(string eventId, EventType eventType) { return(new ThunkAction <AppState>((dispatcher, getState) => { return EventApi.FetchEventDetail(eventId) .Then(eventObj => { if (getState().loginState.isLoggedIn&& eventType == EventType.online) { dispatcher.dispatch(new StartFetchMessagesAction()); dispatcher.dispatch(fetchMessages(eventObj.channelId, "", true)); } var userMap = new Dictionary <string, User> { { eventObj.user.id, eventObj.user } }; eventObj.hosts.ForEach(host => { if (userMap.ContainsKey(host.id)) { userMap[host.id] = host; } else { userMap.Add(host.id, host); } }); dispatcher.dispatch(new UserMapAction { userMap = userMap }); dispatcher.dispatch(new UserLicenseMapAction { userLicenseMap = eventObj.userLicenseMap }); if (getState().eventState.eventsDict.ContainsKey(eventObj.id)) { var oldEventObj = getState().eventState.eventsDict[eventObj.id]; var newEventObj = eventObj; newEventObj.userId = eventObj.user.id; newEventObj.placeId = oldEventObj.placeId; newEventObj.mode = oldEventObj.mode; newEventObj.avatar = oldEventObj.avatar; newEventObj.type = oldEventObj.type; newEventObj.typeParam = oldEventObj.typeParam; eventObj = newEventObj; } eventObj.isNotFirst = true; dispatcher.dispatch(new FetchEventDetailSuccessAction { eventObj = eventObj }); dispatcher.dispatch(new SaveEventHistoryAction { eventObj = eventObj, eventType = eventType }); }) .Catch(error => { dispatcher.dispatch(new FetchEventDetailFailedAction()); Debug.Log(error); }); })); }
public void ApiV1EventPostWithHttpInfo() { configuration = GetClientConfig(); LoggedEvent loggedEvent = new LoggedEvent(dt, "Portal", 1, 7, 1, "anonymous", "Test Event", new Guid("52c5dd34-1b5f-460b-8904-6f0f2897f6a1"), "int.example", 1L); eventApitest = new EventApi(configuration); ApiResponse <object> response = eventApitest.ApiV1EventPostWithHttpInfo(loggedEvent); Assert.Equal(200, response.StatusCode); }
private static void RunIntroEvent(Heroine heroine, PregnancyData preg, bool isPillEvent) { var loadedEvt = GetEvent(heroine, preg, isPillEvent); if (loadedEvt == null) { PregnancyPlugin.Logger.LogError("Unexpected null GetEvent result"); return; } // Init needed first since the custom event starts empty var evt = EventApi.CreateNewEvent(setPlayerParam: true); heroine.SetADVParam(evt); var freePill = _personalityHasPills.TryGetValue(heroine.personality, out var val) && val; evt.Add(Program.Transfer.VAR("bool", "PillForFree", freePill.ToString(CultureInfo.InvariantCulture))); evt.Add(Program.Transfer.VAR("bool", "PlayerHasPill", (StoreApi.GetItemAmountBought(AfterpillStoreId) >= 1).ToString(CultureInfo.InvariantCulture))); // Give favor by default, gets overriden if the event specifies any other value evt.Add(Program.Transfer.VAR("int", "FavorChange", "30")); evt.AddRange(loadedEvt); var scene = TalkScene.instance; scene.StartADV(evt, scene.cancellation.Token) .ContinueWith(() => Program.ADVProcessingCheck(scene.cancellation.Token)) .ContinueWith(() => { PregnancyGameController.ApplyToAllDatas((chara, data) => { if (chara == heroine) { if (isPillEvent) { data.CanAskForAfterpill = false; } else { data.CanTellAboutPregnancy = false; } return(true); } return(false); }); var vars = ActionScene.instance.AdvScene.Scenario.Vars; ApplyStatChangeVars(heroine, preg, vars); // Fix mouth getting permanently locked by the events heroine.chaCtrl.ChangeMouthFixed(false); }) .Forget(); }
// GET: Event/Edit/5 public ActionResult Edit(int id) { var api = new EventApi(_apiSettings.ApiBaseUrl); var model = api.GetEventById(id); ViewData["Title"] = "Events"; ViewData["ApiBaseUrl"] = _apiSettings.ApiBaseUrl; return(View(model)); }
public static object joinEvent(string eventId) { return(new ThunkAction <AppState>((dispatcher, getState) => { return EventApi.JoinEvent(eventId: eventId) .Then(id => { dispatcher.dispatch(new JoinEventSuccessAction { eventId = id }); }) .Catch(error => { dispatcher.dispatch(new JoinEventFailureAction()); Debuger.LogError(message: error); }); })); }
public void HandleEvent(IManager manager, GameEvent gameEvent) { if (manager.IsRunning || overrideEvents.Contains(gameEvent.Type)) { EventApi.OnGameEvent(gameEvent); _eventPublisher.Publish(gameEvent); Task.Factory.StartNew(() => manager.ExecuteEvent(gameEvent)); } else { _logger.LogDebug("Skipping event as we're shutting down {eventId}", gameEvent.Id); } }
public async Task MakesAnExtraCall_NumberOfEventsExactSizeAsOneBatch() { var httpClientWrapper = new FakeEventHttpClientWrapper( resourceName: "resource", events: new List <EventInfo> { new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0") } }, new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("9435310E-098B-4598-A378-5862D9A9E9AE") } }, new EventInfo { EventType = "resource-updated", Event = new TestResourceCreatedEvent { Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0") } } }); var apiHelper = new EventApi("http://localhost/", httpClientWrapper, TestResourceEventConverter.Instance, 3); var result = await apiHelper.GetEventsAfterAsync("resource", lastMessageNumber : MessageNumber.NotSet); Assert.Equal(2, httpClientWrapper.MessagesSent.Count); Assert.Equal("/events/resource/0-2", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath); Assert.Equal("/events/resource/3-5", httpClientWrapper.MessagesSent[1].RequestUri.AbsolutePath); Assert.Equal(3, result.Count); Assert.Equal(new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0"), ((TestResourceCreatedEvent)result[0]).Id); Assert.Equal(new Guid("9435310E-098B-4598-A378-5862D9A9E9AE"), ((TestResourceCreatedEvent)result[1]).Id); Assert.Equal(new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0"), ((TestResourceUpdatedEvent)result[2]).Id); }
public async Task CallsFirstBatchOfEvents_ResponseContentIsEmptyString() { var httpClientWrapper = new MockEventHttpClientWrapper(String.Empty); var apiHelper = new EventApi("http://localhost/", httpClientWrapper, EventConverter.Empty, 10); var result = await apiHelper.GetEventsAfterAsync("resource", lastMessageNumber : MessageNumber.NotSet); Assert.Equal(1, httpClientWrapper.MessagesSent.Count); Assert.Equal("/events/resource/0-9", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath); Assert.NotNull(result); Assert.Empty(result); }
public async Task CallsFirstBatchOfEvents_ResponseHasMultipleEvents() { var httpClientWrapper = new FakeEventHttpClientWrapper( resourceName: "test-message-type", events: new List <EventInfo> { new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0") } }, new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("9435310E-098B-4598-A378-5862D9A9E9AE") } }, new EventInfo { EventType = "resource-created", Event = new TestResourceCreatedEvent { Id = new Guid("73DE4B51-1F0E-4428-8D59-8DFBEA8091BA") } } }); var apiHelper = new EventApi("http://localhost/", httpClientWrapper, TestResourceEventConverter.Instance, 10); var result = await apiHelper.GetEventsAfterAsync("resource", lastMessageNumber : MessageNumber.NotSet); Assert.Equal(1, httpClientWrapper.MessagesSent.Count); Assert.Equal("/events/resource/0-9", httpClientWrapper.MessagesSent[0].RequestUri.AbsolutePath); Assert.Equal(3, result.Count); Assert.Equal(new Guid("7a60d915-a25a-4678-b25e-e35a45a2f0c0"), ((TestResourceCreatedEvent)result[0]).Id); Assert.Equal(new Guid("9435310E-098B-4598-A378-5862D9A9E9AE"), ((TestResourceCreatedEvent)result[1]).Id); Assert.Equal(new Guid("73DE4B51-1F0E-4428-8D59-8DFBEA8091BA"), ((TestResourceCreatedEvent)result[2]).Id); }
public ActionResult Events(int offset = 0, int maxLimit = 20) { var api = new EventApi(_apiSettings.ApiBaseUrl); var model = new ShopEventsViewModel { Events = api.GetEvents(offset, maxLimit) }; ViewData["Title"] = "Events"; ViewData["ApiBaseUrl"] = _apiSettings.ApiBaseUrl; return(View(model)); }
private ApplicationManager() { Logger = new Logger($@"{Utilities.OperatingDirectory}IW4MAdmin.log"); _servers = new List <Server>(); Commands = new List <Command>(); TaskStatuses = new List <AsyncStatus>(); MessageTokens = new List <MessageToken>(); ClientSvc = new ClientService(); AliasSvc = new AliasService(); PenaltySvc = new PenaltyService(); PrivilegedClients = new Dictionary <int, Player>(); Api = new EventApi(); ServerEventOccurred += Api.OnServerEvent; ConfigHandler = new BaseConfigurationHandler <ApplicationConfiguration>("IW4MAdminSettings"); Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey); StartTime = DateTime.UtcNow; }
// GET: Customers/Details/5 public async Task <ActionResult> Details(int?id) { Host eventHost = new Host(); EventApi singleEvent = new EventApi(); double? rating = 0; double count = 0; Session["EventId"] = id; HttpClient client = new HttpClient(); string url = "https://localhost:44355/api/Events"; HttpResponseMessage response = await client.GetAsync(url); string jsonResult = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { EventApi[] events = JsonConvert.DeserializeObject <EventApi[]>(jsonResult); foreach (var item in events) { if (item.EventId == id) { singleEvent = item; eventHost = db.Hosts.Where(h => h.HostId == singleEvent.HostId).FirstOrDefault(); await GetCoord(singleEvent); } } foreach (var item in events) { //pull all categories from events list where category = event category of singleEvent and has host id of eventHost if ((item.Category == singleEvent.Category) && (item.HostId == singleEvent.HostId)) { count++; rating += item.Rating; } } double?avgRating = rating / count; //get average rating //viewbag the event host full name ViewBag.EventHostName = eventHost.FirstName + " " + eventHost.LastName; ViewBag.HostRatingByCategory = avgRating; } return(View(singleEvent)); }
public void Create_ValidEvent_ReturnsEventRegistrationResponse(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var eventApi = new EventApi(client.HttpChannel); var @event = new Event { Name = "My Awesome event", StartDate = DateTime.Now, CompletionDate = DateTime.Now, ExpiryDate = DateTime.Now.AddYears(5), Description = "I'm awesome", EventType = EventType.OtherCelebration.ToString() }; var eventRegistrationResponse = eventApi.Create(@event); Assert.That(eventRegistrationResponse.Id, Is.Not.EqualTo(0)); }
public ActionResult CreateEvent(int id, EventApi @event) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://localhost:44355/api/Events"); string json = JsonConvert.SerializeObject(@event); var content = new StringContent(json, Encoding.UTF8, "Application/json"); var postTask = client.PostAsync("Events", content); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index", "Hosts")); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); return(View(@event)); }
// POST api/News public HttpResponseMessage PostEvent(string id, EventApi newapi) { AccountApiKey apiUser = GetAccount(); EventSourceType eventsType = db.EventSourceTypes.Where(a => a.Title == "API").Single(); EventSource eventsSource = db.EventSources.Where(a => a.CompanyId == apiUser.CompanyId).Where(a => a.EventSourceTypeId == eventsType.EventSourceTypeId).Single(); Event newEvent = new Event(); EventCategory eventCategory = new EventCategory(); Language lang = new Language(); try { eventCategory = db.EventCategories.Where(a => a.Title == newapi.Category).Single(); lang = db.Language.Where(a => a.Culture == newapi.Language).Single(); } catch (Exception err) { return Request.CreateResponse(HttpStatusCode.NotFound); } newEvent.StartTime = newapi.StartTime; newEvent.EndTime = newapi.StartTime.AddMinutes((double)newapi.DurationM); newEvent.CompanyId = apiUser.CompanyId; newEvent.EventCategoryId = eventCategory.EventCategoryId; newEvent.SourceId = id; EventDetail eventDetails = new EventDetail(); eventDetails.Description = newapi.Description; eventDetails.LanguageId = lang.LanguageId; eventDetails.Summary = newapi.Summary; eventDetails.EventId = newEvent.EventId; if (ModelState.IsValid) { db.Events.Add(newEvent); db.EventDetail.Add(eventDetails); db.SaveChanges(); return Request.CreateResponse(HttpStatusCode.Created); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public ShopifyInventoryGet( IPushLogger logger, ProductApi productApi, InventoryApi inventoryApi, EventApi eventApi, ShopifyInventoryRepository inventoryRepository, JobMonitoringService jobMonitoringService, ShopifyBatchRepository batchRepository, ExecutionLogService executionLogService, ShopifyJsonService shopifyJsonService) { _productApi = productApi; _inventoryApi = inventoryApi; _eventApi = eventApi; _inventoryRepository = inventoryRepository; _jobMonitoringService = jobMonitoringService; _batchRepository = batchRepository; _executionLogService = executionLogService; _shopifyJsonService = shopifyJsonService; _logger = logger; }
public ActionResult Create(Event item) { try { var api = new EventApi(_apiSettings.ApiBaseUrl); var model = api.AddEvent(item); ViewData["Title"] = "Events"; ViewData["ApiBaseUrl"] = _apiSettings.ApiBaseUrl; //return View(model); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit(int id, Event e) { try { var api = new EventApi(_apiSettings.ApiBaseUrl); var model = api.UpdateEvent(e); ViewData["Title"] = "Events"; ViewData["ApiBaseUrl"] = _apiSettings.ApiBaseUrl; return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Find(IFormCollection form) { var model = new ShopFindViewModel(); if (!String.IsNullOrEmpty(form["search_param"])) { var sParam = form["search_param"]; var query = new ApiModel.Search { Searchstring = form["search_query"] }; if (sParam == "eventdate") { var api = new EventDateApi(_apiSettings.ApiBaseUrl); model.FullEventDates = api.FindFullEventDates(query); model.PartialView = "_FindEventDatesPartial"; ViewData["Title"] = "Event Dates"; } else if (sParam == "venue") { var api = new VenueApi(_apiSettings.ApiBaseUrl); model.Venues = api.FindVenues(query); model.PartialView = "_FindVenuesPartial"; ViewData["Title"] = "Venues"; } else // sParam == events or something else { var api = new EventApi(_apiSettings.ApiBaseUrl); model.Events = api.FindEvents(query); model.PartialView = "_FindEventsPartial"; ViewData["Title"] = "Events"; } } ViewData["ApiBaseUrl"] = _apiSettings.ApiBaseUrl; return(View("Find", model)); }
public void HandleEvent(IManager manager, GameEvent gameEvent) { #if DEBUG ThreadPool.GetMaxThreads(out int workerThreads, out int n); ThreadPool.GetAvailableThreads(out int availableThreads, out int m); gameEvent.Owner.Logger.WriteDebug($"There are {workerThreads - availableThreads} active threading tasks"); #endif if (manager.IsRunning || overrideEvents.Contains(gameEvent.Type)) { #if DEBUG gameEvent.Owner.Logger.WriteDebug($"Adding event with id {gameEvent.Id}"); #endif EventApi.OnGameEvent(gameEvent); Task.Factory.StartNew(() => manager.ExecuteEvent(gameEvent)); } #if DEBUG else { gameEvent.Owner.Logger.WriteDebug($"Skipping event as we're shutting down {gameEvent.Id}"); } #endif }
public static object fetchEvents(int pageNumber, string tab, string mode) { return(new ThunkAction <AppState>((dispatcher, getState) => { return EventApi.FetchEvents(pageNumber: pageNumber, tab: tab, mode: mode) .Then(eventsResponse => { dispatcher.dispatch(new UserMapAction { userMap = eventsResponse.userMap }); dispatcher.dispatch(new PlaceMapAction { placeMap = eventsResponse.placeMap }); var eventIds = new List <string>(); var eventMap = new Dictionary <string, IEvent>(); eventsResponse.events.items.ForEach(eventObj => { // if (eventObj.mode == "online") return; eventIds.Add(item: eventObj.id); eventMap.Add(key: eventObj.id, value: eventObj); }); dispatcher.dispatch(new EventMapAction { eventMap = eventMap }); dispatcher.dispatch(new FetchEventsSuccessAction { eventIds = eventIds, tab = tab, pageNumber = pageNumber, total = eventsResponse.events.total }); }) .Catch(error => { dispatcher.dispatch(new FetchEventsFailureAction { tab = tab, pageNumber = pageNumber }); Debuger.LogError(message: error); }); })); }
public async Task <ActionResult> Join(Event joinEvent, int id) { joinEvent = new Event(); string userId = User.Identity.GetUserId(); Customer customer = db.Customers.Where(c => c.ApplicationId == userId).SingleOrDefault(); HttpClient client = new HttpClient(); string url = "https://localhost:44355/api/Events/" + id; HttpResponseMessage response = await client.GetAsync(url); string jsonResult = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { EventApi events = JsonConvert.DeserializeObject <EventApi>(jsonResult); joinEvent.EventName = events.EventName; joinEvent.VenueName = events.VenueName; joinEvent.Street = events.Street; joinEvent.Date = events.Date; joinEvent.Category = events.Category; joinEvent.SubCategory = events.SubCategory; joinEvent.City = events.City; joinEvent.State = events.State; joinEvent.ZipCode = events.ZipCode; joinEvent.HostId = events.HostId; db.Events.Add(joinEvent); db.SaveChanges(); CustomerEvent custEvent = new CustomerEvent(); custEvent.EventId = joinEvent.EventId; custEvent.CustomerId = customer.CustomerId; db.CustomerEvents.Add(custEvent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
// PUT api/News/5 public HttpResponseMessage PutEvent(string id, EventApi newapi) { AccountApiKey apiUser = GetAccount(); EventSourceType eventsType = db.EventSourceTypes.Where(a => a.Title == "API").Single(); EventSource eventsSource = db.EventSources.Where(a => a.CompanyId == apiUser.CompanyId).Where(a => a.EventSourceTypeId == eventsType.EventSourceTypeId).Single(); Event newEvent = new Event(); EventCategory eventCategory = new EventCategory(); Language lang = new Language(); try { newEvent = db.Events.Include("EventDetails").Where(a => a.CompanyId == apiUser.CompanyId).Where(c => c.EventSourceId == eventsSource.EventSourceId).Where(b => b.SourceId == id).Single(); eventCategory = db.EventCategories.Where(a => a.Title == newapi.Category).Single(); lang = db.Language.Where(a => a.Culture == newapi.Language).Single(); } catch (Exception err) { return Request.CreateResponse(HttpStatusCode.NotFound); } newEvent.StartTime = newapi.StartTime; newEvent.EndTime = newapi.StartTime.AddMinutes((double)newapi.DurationM); EventDetail eventDetails = new EventDetail(); var eventDetailCnt = (from a in newEvent.EventDetails where a.LanguageId == lang.LanguageId select a); if (eventDetailCnt.Count() == 1) eventDetails = eventDetailCnt.First(); eventDetails.Description = newapi.Description; eventDetails.LanguageId = lang.LanguageId; eventDetails.Summary = newapi.Summary; eventDetails.EventId = newEvent.EventId; if (ModelState.IsValid) { //db.Entry(news).State = EntityState.Modified; try { if (eventDetailCnt.Count() == 0) db.EventDetail.Add(eventDetails); db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }