Example #1
0
        public ListEventsResponse ListEvents(ListEventsRequest request)
        {
            var command = new ListEvents(_apiKey, _secret, _baseUri, _authenticator, _builder)
            {
                Parameters = request
            };

            return((ListEventsResponse)((ICommandExecutor)this).Execute(command));
        }
 public ExtensionFromPlugin(Lifetime lifetime, Plugin plugin, IExtensionProvider provider,
                            ExtensionLocations extensionLocations)
 {
     this.plugin             = plugin;
     this.extensionLocations = extensionLocations;
     Id                 = plugin.ID;
     Enabled            = new Property <bool?>(lifetime, string.Format("ExtensionFromPlugin:{0}", Id));
     RuntimeInfoRecords = new ListEvents <ExtensionRecord>(lifetime,
                                                           string.Format("ExtensionFromPlugin:{0}", Id));
     Source   = provider;
     Metadata = new ExtensionFromPluginMetadata(plugin);
 }
        public VsixExtension(IExtensionProvider provider, NuSpec nuSpec, FileSystemPath location, 
      ExtensionLocations extensionLocations)
        {
            var source = GetType().Name;

              this.nuSpec = nuSpec;
              this.location = location;
              this.extensionLocations = extensionLocations;

              Version = new Version(nuSpec.Version);
              Metadata = new VsixExtensionMetadata(nuSpec);
              Supported = true; // TODO
              Enabled = new Property<bool?>(string.Format("{0}::Enabled", source), null);
              RuntimeInfoRecords = new ListEvents<ExtensionRecord>(string.Format("{0}::RuntimeInfoRecords", source));
              Source = provider;
        }
        public IHttpActionResult ListAllEvents()
        {
            try
            {
                ListEvents response = new ListEvents();
                response.events = db.Events.ToList();

                if (response.events == null || (response.events != null && response.events.Count() == 0))
                {
                    return(Content(HttpStatusCode.NotFound, "The events are not Found"));
                }

                return(Content(HttpStatusCode.OK, response));
            }
            catch (Exception)
            {
                return(Content(HttpStatusCode.InternalServerError, "Iternal server error"));
            }
        }
        public StringListViewModel(
            [NotNull] Lifetime lifetime,
            [NotNull] Property <string> source)
        {
            myLifetime     = lifetime;
            mySource       = source;
            myEntryChanged = new GroupingEventHost(lifetime, false).CreateEvent(lifetime,
                                                                                "StringListViewModel.EntryChangedGrouped",
                                                                                TimeSpan.FromMilliseconds(100),
                                                                                OnEntryChanged);

            var entries = mySource.Value.SplitByNewLine()
                          .Where(entry => !entry.IsEmpty())
                          .Select(entry => new StringListEntry(lifetime, myEntryChanged.Incoming, entry.Trim()))
                          .ToList();

            Entries       = new ListEvents <StringListEntry>(lifetime, "StringListViewModel.Entries", entries, false);
            SelectedEntry = new Property <StringListEntry>(lifetime, "StringListViewModel.SelectedEntry");
        }
Example #6
0
        public ActionResult List()
        {
            ListEvents ViewModel = new ListEvents();

            ViewModel.isadmin = User.IsInRole("Admin");

            string url = "EventData/GetEvents";
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                IEnumerable <EventDto> SelectedEvents = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result;
                ViewModel.events = SelectedEvents;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public IHttpActionResult Event(int id)
        {
            try
            {
                if (id <= 0)
                {
                    return(Content(HttpStatusCode.BadRequest, "Not a valid id"));
                }

                ListEvents response = new ListEvents();
                response.events = db.Events.Where(e => e.Id == id).ToList();

                if (response.events == null || (response.events != null && response.events.Count() == 0))
                {
                    return(Content(HttpStatusCode.NotFound, "The event is not Found"));
                }

                return(Content(HttpStatusCode.OK, response));
            }
            catch (Exception)
            {
                return(Content(HttpStatusCode.InternalServerError, "Iternal server error"));
            }
        }
        // List Events:
        public ActionResult List(string searchkey = "", string campus = "", int pagenum = 0)
        {
            ListEvents viewmodel = new ListEvents();

            viewmodel.HospitalCampuses = db.HospitalCampuses.ToList();

            Debug.WriteLine("The searchkey is " + searchkey);

            if (searchkey != "")
            {
                List <Event> Events = db.Events
                                      .Where(Event =>
                                             Event.EventTitle.Contains(searchkey) ||
                                             Event.EventDescription.Contains(searchkey) ||
                                             Event.EventLocation.Contains(searchkey)
                                             ).ToList();
                viewmodel.Events = Events;
            }
            else if (campus != "")
            {
                // Must parse to int value to check against DB values:
                int          campusid = int.Parse(campus);
                List <Event> Events   = db.Events.Where(h => h.CampusID == campusid).ToList();
                viewmodel.Events = Events;
            }
            else
            {
                List <Event> Events = db.Events.ToList();
                viewmodel.Events = Events;
            }


            // Pagination for List of Events:

            // "perpage": number of records per page
            int perpage    = 3;
            int eventcount = viewmodel.Events.Count();
            // "maxpage": -1 to offset index starting at 0
            int maxpage = (int)Math.Ceiling((decimal)eventcount / perpage) - 1;

            // "maxpage": max number of pages. Obtained by taking total number of records divided by the number of records perpage (round up)
            if (maxpage < 0)
            {
                maxpage = 0;
            }
            // "pagenum": current page
            if (pagenum < 0)
            {
                pagenum = 0;
            }
            if (pagenum > maxpage)
            {
                pagenum = maxpage;
            }
            // "start": describes which record we start on. Obtained by multiplying the number of records per page by the total number of pages:
            int start = (int)(perpage * pagenum);

            // Get maxpage value so to only display pagination if there are more than 3 records in the PatientEcards table:
            ViewData["maxpage"]     = maxpage;
            ViewData["pagenum"]     = pagenum;
            ViewData["pagesummary"] = "";
            if (maxpage > 0)
            {
                ViewData["pagesummary"] = (pagenum + 1) + " of " + (maxpage + 1);
                if (searchkey != "")
                {
                    viewmodel.Events = db.Events
                                       .Where(Event =>
                                              Event.EventTitle.Contains(searchkey) ||
                                              Event.EventDescription.Contains(searchkey) ||
                                              Event.EventLocation.Contains(searchkey))
                                       .OrderBy(Event => Event.EventDate)
                                       .Skip(start)
                                       .Take(perpage)
                                       .ToList();
                }
                else if (campus != "")
                {
                    int          campusid = int.Parse(campus);
                    List <Event> Events   = db.Events.Where(h => h.CampusID == campusid)
                                            .OrderBy(Event => Event.EventDate)
                                            .Skip(start)
                                            .Take(perpage)
                                            .ToList();
                    viewmodel.Events = Events;
                }
                else
                {
                    List <Event> Events = db.Events
                                          .OrderBy(Event => Event.EventDate)
                                          .Skip(start)
                                          .Take(perpage)
                                          .ToList();
                    viewmodel.Events = Events;
                }
                // End of LINQ pagination algorithm
            }


            return(View(viewmodel));
        }
Example #9
0
        async void Save_Clicked(object sender, EventArgs e)
        {
            try
            {
                App.localizer.SetLocale(App.defaultCulture);
                Loading.IsRunning = true;
                Loading.IsVisible = true;
                RestClient restClient = App.restClient;
                Alert      alerts     = new Alert();
                alerts.User = App.user;

                if (alerts.User == null)
                {
                    await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String186"), "Ok");
                }
                else
                {
                    if (this.alert == null)
                    {
                        alerts.Event = new Event();
                        if (ListEvents.Any())
                        {
                            alerts.Event = ListEvents[picEvent.SelectedIndex];
                        }
                        alerts.Content     = Content;
                        alerts.Title       = txtTitle.Text;
                        alerts.CreatedTime = DateTime.Now;
                        //Save alerts
                        var result = await restClient.PostAsync("alerts", alerts);

                        if (result.Equals(ApiStatusConstant.SUCCESS))
                        {
                            restClient.AddEvent("ADD_WARNING");
                            await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String202"), "Ok");

                            //App.bottomTabbedPage.SelectedItem = App.bottomTabbedPage.Children[2];
                            var existingPages = Navigation.NavigationStack.ToList();
                            for (int i = 1; i < existingPages.Count; i++)
                            {
                                Navigation.RemovePage(existingPages[i]);
                            }
                        }
                        else
                        {
                            await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String203"), "Ok");
                        }
                    }
                    else
                    {
                        var alert1 = await restClient.Get <Alert>("alerts/" + alert.AlertId);

                        if (alert1 != null)
                        {
                            alert1.User  = App.user;
                            alert1.Event = new Event();
                            if (ListEvents.Any())
                            {
                                alert1.Event = ListEvents[picEvent.SelectedIndex];
                            }
                            alert1.Content = Content;
                            alert1.Title   = txtTitle.Text;
                            //Save alerts
                            var result = await restClient.PutAsync("alerts", alert1, alert1.AlertId);

                            if (result.Equals(ApiStatusConstant.SUCCESS))
                            {
                                restClient.AddEvent("UPDATE_WARNING");
                                await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String204"), "Ok");

                                //App.bottomTabbedPage.SelectedItem = App.bottomTabbedPage.Children[2];
                                var existingPages = Navigation.NavigationStack.ToList();
                                for (int i = 1; i < existingPages.Count; i++)
                                {
                                    Navigation.RemovePage(existingPages[i]);
                                }
                            }
                            else
                            {
                                await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String205"), "Ok");
                            }
                        }
                        else
                        {
                            await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String205"), "Ok");
                        }
                    }
                }
                Loading.IsVisible = false;
                Loading.IsRunning = false;
            }
            catch (Exception ex)
            {
                await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String205"), "Ok");
            }
        }