Esempio n. 1
0
        public async Task <PrivateNote> AddPrivateNote(string message, string userId)
        {
            if (await _users.Find <User>(x => x.Id == userId).FirstOrDefaultAsync() == null)
            {
                return(null);
            }

            PrivateNote note = new PrivateNote {
                Message      = message,
                UserId       = userId,
                CreationDate = new Date {
                    Day    = DateTime.Now.Day.ToString(),
                    Month  = DateTime.Now.Month.ToString(),
                    Year   = DateTime.Now.Year.ToString(),
                    Minute = DateTime.Now.Minute.ToString(),
                    Hour   = DateTime.Now.Hour.ToString()
                }
            };

            await _privateNotes.InsertOneAsync(note);

            return(note);
        }
Esempio n. 2
0
        public bool AddDocs()
        {
            string numberofitemsbeforepublish;
            string numberofitemsafterpublish;

            try
            {
                string currentURL = Driver.Instance.Url;
                Pages.TraverseBufferPage.EditThisList();
                WaitFind.FindElem(PrivateNote, 10);
                PrivateNote.SendKeys("Concepts of Physics");
                Thread.Sleep(KortextGlobals.s);
                WaitFind.FindElem(PublicNote, 10);
                PublicNote.SendKeys("Basics of Physics");
                Thread.Sleep(KortextGlobals.s);
                WaitFind.FindElem(ListSummary, 10);
                ListSummary.SendKeys("Physics");
                Thread.Sleep(KortextGlobals.s);
                new SelectElement(NewTemplateList).SelectByIndex(1);
                Thread.Sleep(KortextGlobals.s);

                IList <IWebElement> AddDocuments_Icon = new List <IWebElement>(Driver.Instance.FindElements(AddDocument_locator));
                if (AddDocuments_Icon.Count > 0 && AddDocuments_Icon.Count > 7)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        switch (i)
                        {
                        case 7:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("Canada", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 6:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("India", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 5:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("British", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 4:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("France", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 3:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("Australia", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 2:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("Singapore", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 1:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("Thailand", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        case 0:
                            Klick.On(AddDocuments_Icon[i]);
                            Thread.Sleep(KortextGlobals.s);
                            Pages.PearlEditBuffer.AddCitations("Africa", "WorldCat");
                            Thread.Sleep(KortextGlobals.s);
                            break;

                        default:
                            Console.WriteLine("Incorrect Add Document Icon fetched.");
                            return(false);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Either Add Documents icon NOT present in the List Page, or less number of Add Documents icons present on the screen.");
                    return(false);
                }

                numberofitemsbeforepublish = Pages.PearlEditBuffer.DisplayTotalNumberofItems();
                Pages.PearlEditBuffer.PublishingList();

                //Verify the action performed above
                Driver.Instance.Url = currentURL;
                Driver.Instance.Navigate().Refresh();
                Thread.Sleep(KortextGlobals.l);
                Pages.TraverseBufferPage.EditThisList();
                numberofitemsafterpublish = Pages.PearlEditBuffer.DisplayTotalNumberofItems();

                if (numberofitemsbeforepublish == numberofitemsafterpublish)
                {
                    Pages.PearlEditBuffer.PublishingList();
                    Console.WriteLine("Adding Initial Documents to List Completed");
                    return(true);
                }
                else
                {
                    Console.WriteLine("Error Adding Initial Documents to List.");
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in PearlNewListAddDocs.cs: " + e.Message);
                return(false);
            }
        }