private void Create_Button_Clicked(object s, EventArgs e)
        {
            programareaCurenta.comments = coment.Text;

            if (programareaCurenta.prog_name != "" & programareaCurenta.id_doctor != "" &
                programareaCurenta.id_procedure != "" & programareaCurenta.hour != ""
                & programareaCurenta.id_user != "" & programareaCurenta.comments != "")
            {
                AvailableDay day = Services.AllAvailableDayLilst.Where(itm => itm.dayname == programareaCurenta.prog_name & itm.doctor_id == selectedDoctor.id.ToString()).FirstOrDefault();
                if (day == null)
                {
                    if (isDayValid)
                    {
                        Services.RegisterProgramation(programareaCurenta);
                        AvailableDay dday = new AvailableDay()
                        {
                            dayname    = programareaCurenta.prog_name,
                            work_hours = 1,
                            hours_list = programareaCurenta.hour + ",",
                            doctor_id  = selectedDoctor.id.ToString()
                        };
                        Services.RegisterDayAvailability(dday);
                        this.OnBackPressed();
                    }
                    else
                    {
                        Toast.MakeText(this, "This date is not valable!", ToastLength.Short).Show();
                    }
                }
                else
                {
                    if (isDayValid)
                    {
                        if (selectedDay.hours_list.Split(',').Length < 9)
                        {
                            selectedDay.hours_list += programareaCurenta.hour + ",";
                            selectedDay.work_hours++;
                            Services.UpdateDayAvailability(selectedDay);
                            Services.RegisterProgramation(programareaCurenta);
                            //this.GoPage(typeof(HomeUser));
                            this.OnBackPressed();
                        }
                        else
                        {
                            Toast.MakeText(this, "This day is busy", ToastLength.Short).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, "This date is not valid!", ToastLength.Short).Show();
                    }
                }
            }
            else
            {
                Toast.MakeText(this, "All Procedure content is not completed", ToastLength.Short).Show();
            }
        }
        private static UIElement ToView(this AvailableDay availableDay)
        {
            var border = new Border()
            {
                BorderThickness = new Thickness(1)
            };

            border.SetValue(Grid.RowProperty, availableDay.WeekIndex);
            border.SetValue(Grid.ColumnProperty, availableDay.DayIndex);
            border.BorderBrush = Brushes.DarkGray;

            border.Child = availableDay.Date.Day.ToString().DateBox();

            return(border);
        }
        public void UpdateDayAvailability(AvailableDay newday)
        {
            string responseJsonString = null;

            using (var httpClient = new WebClient())
            {
                try
                {
                    responseJsonString = httpClient.DownloadString(UrlConstant.BaseUrl + UrlConstant.DayAvailabilityUpdate +
                                                                   newday.id + '.' +
                                                                   newday.hours_list + '.' + newday.work_hours);// + '.' + newday.doctor_id
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public void RegisterDayAvailability(AvailableDay day)
        {
            string responseJsonString = null;

            using (var httpClient = new WebClient())
            {
                try
                {
                    responseJsonString = httpClient.DownloadString(UrlConstant.BaseUrl + UrlConstant.DayAvailabilityRegister +
                                                                   day.dayname + '.' +
                                                                   day.hours_list + '.' + day.work_hours + '.' + day.doctor_id);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public void OnDateSet(DatePicker view, int _year, int _month, int _day)
        {
            this.year  = _year;
            this.month = _month + 1;
            this.day   = _day;
            DateTime selected = new  DateTime(this.year, this.month, this.day);
            DateTime curent   = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);

            if (DateTime.Compare(selected, curent) > 0)
            {
                isDayValid = true;
            }
            else
            {
                isDayValid = false;
            }

            programareaCurenta.prog_name = day + "" + month + "" + year;
            avaylableDays   = Services.GetAvailableDay();
            selectDate.Text = "Selected date: " + day + "/" + month + "/" + year;
            selectedDay     = Services.AllAvailableDayLilst.Where(itm => itm.dayname == programareaCurenta.prog_name & itm.doctor_id == selectedDoctor.id.ToString()).FirstOrDefault();

            if (selectedDay != null)
            {
                List <string> usedHoursList   = selectedDay.hours_list.Split(',').ToList();
                List <int>    unUsedHoursList = new List <int>();

                foreach (var item in hours)
                {
                    if (!usedHoursList.Contains(item + ""))
                    {
                        unUsedHoursList.Add(item);
                    }
                }

                ArrayAdapter hours_adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, unUsedHoursList);
                hourSpin.Adapter = hours_adapter;
            }
            else
            {
                ArrayAdapter hours_adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, hours);
                hourSpin.Adapter = hours_adapter;
            }
        }
 public static void UpdateDayAvailability(AvailableDay day)
 {
     _resources.UpdateDayAvailability(day);
 }
 public static void RegisterDayAvailability(AvailableDay day)
 {
     _resources.RegisterDayAvailability(day);
 }
        public void AddNewSkill()
        {
            //Populate the Excel Sheet
            Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Shareskills");
            GlobalDefinitions.wait(1);

            //Enter a Title
            Title.SendKeys(ExcelLib.ReadData(2, "Title"));
            Base.test.Log(LogStatus.Info, "Added Title successfully");

            // Enter description
            Description.SendKeys(ExcelLib.ReadData(2, "Description"));
            Base.test.Log(LogStatus.Info, "Added description successfully");

            //Select a category from dropdown
            GlobalDefinitions.wait(2);
            //Thread.Sleep(500);
            Actions action = new Actions(GlobalDefinitions.driver);

            action.MoveToElement(SkillCategory).Build().Perform();
            Thread.Sleep(1000);
            IList <IWebElement> SkillCategorylist = SkillCategory.FindElements(By.TagName("option"));
            int count = SkillCategorylist.Count;

            Thread.Sleep(1500);
            for (int i = 1; i < count; i++)
            {
                if (SkillCategorylist[i].Text == ExcelLib.ReadData(2, "Category").Trim())
                {
                    Thread.Sleep(500);
                    SkillCategorylist[i].Click();
                    Base.test.Log(LogStatus.Info, "Added category successfully");
                }
            }

            //Select a subcategory from dropdown
            GlobalDefinitions.wait(2);
            action.MoveToElement(SubCategory).Build().Perform();
            GlobalDefinitions.wait(2);
            IList <IWebElement> SubCategorylist = SubCategory.FindElements(By.TagName("option"));

            for (int i = 0; i < SubCategorylist.Count; i++)
            {
                if (SubCategorylist[i].Text == ExcelLib.ReadData(2, "SubCategory"))
                {
                    SubCategorylist[i].Click();
                    Base.test.Log(LogStatus.Info, "Added Subcategory successfully");
                }
            }

            //Add Tag
            GlobalDefinitions.wait(2);
            Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tag"));
            Tags.SendKeys(Keys.Enter);
            Base.test.Log(LogStatus.Info, "Added tag successfully");

            //Select Service type
            GlobalDefinitions.wait(2);
            string ExpectedService = GlobalDefinitions.ExcelLib.ReadData(2, "Service");
            string ActualService   = ServiceType1.Text;

            if (ExpectedService == ActualService)
            {
                ServiceType1.Click();
            }
            else
            {
                ServiceType2.Click();
            }

            //Select location type
            Thread.Sleep(2000);
            GlobalDefinitions.wait(2);
            string ExpectedLocation = ExcelLib.ReadData(2, "Location");
            string ActualLocation   = Location1.Text;

            if (ExpectedLocation == ActualLocation)
            {
                Location1.Click();
            }
            else
            {
                GlobalDefinitions.wait(2);
                Location2.Click();
            }


            ////Select start Date
            GlobalDefinitions.wait(2);
            //StartDate.SendKeys(ExcelLib.ReadData(2, "StartDate"));
            //StartDate.SendKeys(Keys.Tab);
            Thread.Sleep(2000);
            string sysday = DateTime.Today.Day.ToString();

            StartDate.SendKeys(sysday);

            string sysmonth = DateTime.Today.Month.ToString();

            StartDate.SendKeys(sysmonth);

            // Select EndDate
            Thread.Sleep(2000);
            // EndDate.SendKeys(ExcelLib.ReadData(2, "EndDate"));
            EndDate.SendKeys("20/11/2020");
            GlobalDefinitions.wait(2);

            //Select Available day
            Thread.Sleep(2000);
            AvailableDay.Click();

            // Select StartTime
            Thread.Sleep(2000);
            StartTime.SendKeys(ExcelLib.ReadData(2, "StartTime"));
            Thread.Sleep(2000);

            // Select EndTime
            GlobalDefinitions.wait(1);
            EndTime.SendKeys(ExcelLib.ReadData(2, "EndTime"));
            Base.test.Log(LogStatus.Info, "Added avilable date and time successfully");
            Thread.Sleep(2000);

            //Select Skill Trade
            GlobalDefinitions.wait(2);
            string ExpectedSkillTrade = ExcelLib.ReadData(2, "Skill Trade");
            string ActualSkillTrade   = SkillExchange.Text;

            if (ExpectedSkillTrade == ActualSkillTrade)
            {
                SkillExchange.Click();
                //Enter skill for exchange
                SkillExchangeTag.SendKeys(ExcelLib.ReadData(2, "Skillexchange"));
            }
            else
            {
                Credit.Click();
                //Enter rate
                CreditRate.Clear();
                CreditRate.SendKeys(ExcelLib.ReadData(2, "Rate"));
            }

            //Upload WorkSample Images
            string MyWork = ExcelLib.ReadData(2, "UploadImage");

            WorkSample.Click();
            AutoItX3 autoit = new AutoItX3();

            autoit.WinActivate("Open");
            autoit.Send(MyWork);
            GlobalDefinitions.wait(1);
            autoit.Send("{Enter}");
            Base.test.Log(LogStatus.Info, "Uploaded image successfully");
            Thread.Sleep(2000);

            //Select active/ Hidden button
            GlobalDefinitions.wait(1);
            GlobalDefinitions.wait(2);
            string ExpectedAction = ExcelLib.ReadData(2, "Location");
            string ActualAction   = ActiveBtn.Text;

            if (ExpectedAction == ActualAction)
            {
                ActiveBtn.Click();
            }
            else
            {
                GlobalDefinitions.wait(2);
                HiddenBtn.Click();
            }

            //Check if save button enabled
            GlobalDefinitions.wait(2);
            if (SaveBtn.Enabled)
            {
                // Click on Save button
                GlobalDefinitions.wait(2);
                SaveBtn.Click();
                Thread.Sleep(10000);
                try
                {
                    //Check for Skill share success message
                    Thread.Sleep(2000);
                    GlobalDefinitions.wait(2);
                    String ExpectedMessage = "Service Listing Added Successfully";
                    Thread.Sleep(10000);
                    String ActualMessage = driver.FindElement(By.CssSelector("div.ns-box-inner")).Text;
                    Assert.AreEqual(ExpectedMessage, ActualMessage);
                    Base.test.Log(LogStatus.Info, "Skill saved Successfully");
                }
                catch (Exception)
                {
                    Base.test.Log(LogStatus.Info, "Skill saved Successfully");
                }
            }
            else
            {
                SaveScreenShotClass.SaveScreenshot(driver, "Save button not enabled");
                Base.test.Log(LogStatus.Info, "Save button not enabled");
            }


            //Search for the Shared skill in Manage Listing page

            GlobalDefinitions.wait(2);

            //Click on manage listing
            driver.FindElement(By.LinkText("Manage Listings")).Click();
            Thread.Sleep(1000);

            //Check if navigated to service listing page
            try
            {
                string Expected = "Manage Listings";
                string Actual   = driver.FindElement(By.XPath("//div[@id='listing-management-section']/div[2]/h2")).Text;
                Assert.AreEqual(Expected, Actual);

                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Navigated to manage listing page");
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Navigated to manage listing page");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }
            catch (Exception)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Could not navigate to Manage listing page");
                string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Could not navigate to Manage listing page");
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
            }

            //Check if the added skill is present in the Manage listings
            GlobalDefinitions.wait(2);
            string ExpectedTitle = ExcelLib.ReadData(2, "Title");

            string BeforeXPath = "//div[@id='listing-management-section']/div[2]/div/table/tbody/tr[";
            string AfterXpath  = "]/td[3]";

            for (int i = 1; i <= 5; i++)
            {
                GlobalDefinitions.wait(2);
                string ColElements = driver.FindElement(By.XPath(BeforeXPath + i + AfterXpath)).Text;

                if (ColElements.Contains(ExpectedTitle))
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Skill present in Manage Listing ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill present in Manage Listing");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                    break;
                }
                else
                {
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Skill not present in Manage Listing ");
                    string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Skill not present in Manage Listing");
                    Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath));
                }
            }
        }