Exemple #1
0
 private void CloseButt_Click(object sender, RoutedEventArgs e)
 {
     resizecheck.IsChecked      = false;
     SkinsListbox.SelectedIndex = 0;
     this.Hide();
     CustomMethods.SaveConfig();
 }
        public ActionResult AddEditCountry(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("Country");
            if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            CountryModel CountryModel = new CountryModel();
            int          take         = 10;
            int          skip         = take * pid;

            CountryModel.PageID  = pid;
            CountryModel.Current = pid + 1;
            ViewBag.c            = CountryModel.PageID;
            if (id != 0)
            {
                var objcountry = new CountryBLL {
                }.GetCountryById(id);
                if (objcountry != null)
                {
                    CountryModel.CountryId   = objcountry.CountryId;
                    CountryModel.CountryName = objcountry.CountryName;
                    CountryModel.CountryCode = objcountry.CountryCode;
                    CountryModel.IsActive    = Convert.ToBoolean(objcountry.IsActive);
                }
            }
            return(View(CountryModel));
        }
Exemple #3
0
 private void SkinsListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     if (SkinsListbox.SelectedItem != null)
     {
         CustomMethods.SkinList_Information(((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString());
     }
 }
Exemple #4
0
        //
        public ActionResult Index(int pid = 0, int cid = 0)
        {
            try
            {
                int take;
                int skip;
                take = 10;
                skip = take * pid;
                ModulesModel ModuleModel = new ModulesModel();
                ModuleModel.PageID  = pid;
                ModuleModel.Current = pid + 1;

                var modulelist = new ModuleBLL {
                }.GetAllModules(skip, take);
                if (modulelist != null)
                {
                    double count = Convert.ToDouble(new ModuleBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    ModuleModel.Pagecount  = (int)Math.Ceiling(res);
                    ModuleModel.ModuleList = modulelist;
                }
                CustomMethods.ValidateRoles("Module");
                return(View(ModuleModel));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public ActionResult AddEditState(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("State");
            if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            StateModel StateModel = new StateModel();
            int        take       = 10;
            int        skip       = take * pid;

            StateModel.PageID  = pid;
            StateModel.Current = pid + 1;
            ViewBag.c          = StateModel.PageID;
            if (id != 0)
            {
                var objstate = new StateBLL {
                }.GetSubStateById(id);
                if (objstate != null)
                {
                    StateModel.StateId   = objstate.StateId;
                    StateModel.StateName = objstate.StateName;
                    StateModel.CountryId = objstate.CountryId;
                    StateModel.IsActive  = Convert.ToBoolean(objstate.IsActive);
                }
            }
            CustomMethods.BindCountryList(StateModel);
            return(View(StateModel));
        }
Exemple #6
0
        private void CreateSkin_Click(object sender, RoutedEventArgs e)
        {
            string skin = ((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString();

            if (skin == "Create New Skin")
            {
                CustomMethods.CreateModifySkin(@"\" + SkinName_TextBox.Text, SkinName_TextBox.Text, SkinAuthor_TextBox.Text, SkinVersion_TextBox.Text, CustomMethods.ScreenShotPath, SkinNotes_TextBox.Text);

                CustomMethods.CurrentSkin = @"\" + SkinName_TextBox.Text;
                CustomMethods.SaveCurrentState();
                //copy img, load img, then save
                if (!string.IsNullOrWhiteSpace(CustomMethods.Imagepath))
                {
                    string temp = CustomMethods.Imagepath;
                    CustomMethods.Imagepath = "";
                    CustomMethods.LoadImage(temp);
                }

                CustomMethods.SaveConfig();
                CustomMethods.GetSkinList();
            }
            else
            {
                if ((@"\" + skin) == CustomMethods.CurrentSkin)
                {
                    CustomMethods.SaveConfig();
                }
                CustomMethods.CreateModifySkin(skin, SkinName_TextBox.Text, SkinAuthor_TextBox.Text, SkinVersion_TextBox.Text, CustomMethods.ScreenShotPath, SkinNotes_TextBox.Text);
            }
        }
Exemple #7
0
        private static void FirstRun(string appdatapath, string curFileName)
        {
            try {
                //MessageBox.Show("DEBUG: creating folder");
                Directory.CreateDirectory(appdatapath);
                //MessageBox.Show("DEBUG: copying exe file");
                System.IO.File.Copy(curFileName, appdatapath + "\\" + "SkinText.exe", true);
                //MessageBox.Show("DEBUG: creating default skin folder");
                Directory.CreateDirectory(appdatapath + @"\Default");
                //MessageBox.Show("DEBUG: creating desktop shortcut");
                CreateShortcut(appdatapath);
                if (!System.IO.File.Exists(appdatapath + "\\" + "config.ini"))
                {
                    CustomMethods.CurrentSkin = @"\Default";
                    //MessageBox.Show("DEBUG: setting default skin");
                    CustomMethods.SaveCurrentState();
                    //skininfo.ini Area
                    //MessageBox.Show("DEBUG: creating default skin config");
                    CustomMethods.CreateModifySkin("Default", "Default", "FrostHive", "2.0.0", "DefaultIcon", "SkinText Default Skin");
                    //skininfo.ini Area
                }
            }
            catch (Exception ex) {
                //MessageBox.Show("Error creating Initial Config", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
#if DEBUG
                MessageBox.Show("DEBUG: " + ex.ToString());
#endif
                throw;
            }
        }
Exemple #8
0
        //
        // GET: /Admin/Role/

        public ActionResult Index(int pid = 0)
        {
            try
            {
                int       take         = 10;
                int       skip         = take * pid;
                RoleModal objRoleModal = new RoleModal();
                objRoleModal.PageID  = pid;
                objRoleModal.Current = pid + 1;

                var rolelist = new RolesBLL {
                }.GetAllRoles(skip, take);
                if (rolelist != null)
                {
                    double count = Convert.ToDouble(new RolesBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    objRoleModal.Pagecount = (int)Math.Ceiling(res);
                    objRoleModal.Roleslist = rolelist;
                }
                CustomMethods.ValidateRoles("Role");
                return(View(objRoleModal));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public ActionResult AddEditCity(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("City");
            if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            CityModel CityModel = new CityModel();
            int       take      = 10;
            int       skip      = take * pid;

            CityModel.PageID  = pid;
            CityModel.Current = pid + 1;
            ViewBag.c         = CityModel.PageID;
            if (id != 0)
            {
                var objcity = new CityBLL {
                }.GetSubCityById(id);
                if (objcity != null)
                {
                    CityModel.CityId   = objcity.CityId;
                    CityModel.CityName = objcity.CityName;
                    CityModel.StateId  = objcity.StateId;
                    CityModel.IsActive = Convert.ToBoolean(objcity.IsActive);
                }
            }
            CustomMethods.BindStateList(CityModel);
            return(View(CityModel));
        }
        public ActionResult ViewState(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("State");
            if (!Convert.ToBoolean(Session["IsAdd"]) && !Convert.ToBoolean(Session["IsEdit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            StateModel state = new StateModel();
            int        take  = 10;
            int        skip  = take * pid;

            state.PageID  = pid;
            state.Current = pid + 1;
            ViewBag.c     = state.PageID;
            if (id != 0)
            {
                var objState = new StateBLL {
                }.GetSubStateById(id);
                if (objState != null)
                {
                    state.StateId     = objState.StateId;
                    state.StateName   = objState.StateName;
                    state.CountryId   = objState.CountryId; //== null ? 0 : Convert.ToInt32(objcourse.CountryId);
                    state.CountryName = objState.CountryName;
                    state.IsActive    = Convert.ToBoolean(objState.IsActive);
                }
            }
            return(View(state));
        }
Exemple #11
0
        void step()
        {
            int   N    = this.size;
            float visc = this.visc;
            float diff = this.diff;
            float dt   = this.dt;

            float[] Vx      = this.Vx;
            float[] Vy      = this.Vy;
            float[] Vx0     = this.Vx0;
            float[] Vy0     = this.Vy0;
            float[] s       = this.s;
            float[] density = this.density;

            CustomMethods.diffuse(1, Vx0, Vx, visc, dt);
            CustomMethods.diffuse(2, Vy0, Vy, visc, dt);

            CustomMethods.project(Vx0, Vy0, Vx, Vy);

            CustomMethods.advect(1, Vx, Vx0, Vx0, Vy0, dt);
            CustomMethods.advect(2, Vy, Vy0, Vx0, Vy0, dt);

            CustomMethods.project(Vx, Vy, Vx0, Vy0);

            CustomMethods.diffuse(0, s, density, diff, dt);
            CustomMethods.advect(0, density, s, Vx, Vy, dt);
        }
        public ActionResult ViewCity(int id = 0, int pid = 0)
        {
            CustomMethods.ValidateRoles("City");
            if (!Convert.ToBoolean(Session["Add"]) && !Convert.ToBoolean(Session["Edit"]))
            {
                return(View("ErrorPage", "Error"));
            }
            CityModel city = new CityModel();
            int       take = 10;
            int       skip = take * pid;

            city.PageID  = pid;
            city.Current = pid + 1;
            ViewBag.c    = city.PageID;
            if (id != 0)
            {
                var objcity = new CityBLL {
                }.GetSubCityById(id);
                if (objcity != null)
                {
                    city.CityId    = objcity.CityId;
                    city.CityName  = objcity.CityName;
                    city.StateName = objcity.StateName;
                    city.IsActive  = Convert.ToBoolean(objcity.IsActive);
                }
            }
            return(View(city));
        }
        //Login function
        public void Login()
        {
            ExcelLib.PopulateInCollection(Base.ExcelDataPath, "Login");
            Console.WriteLine("Opening the application");
            CommonMethods.driver.Navigate().GoToUrl(KeysResource.Url);
            CommonMethods.driver.Manage().Window.Maximize();
            Thread.Sleep(1000);

            UserName.SendKeys(ExcelLib.ReadData(1, "Username"));
            Password.SendKeys(ExcelLib.ReadData(1, "Password"));

            loginButton.Submit();
            Assert.AreEqual("Dashboard", CommonMethods.driver.Title);
            if (CommonMethods.driver.Title == "Dashboard")
            {
                Base.test.Log(Status.Pass, "Logged in to application successfully");
            }
            else
            {
                Base.test.Log(Status.Fail, "Failed to login to application.Pls check screenshot " + CommonMethods.SaveScreenshot());
            }

            Console.WriteLine("Logged in to application");

            //Clicking on Skip button
            if (CustomMethods.IsElementPresent(By.LinkText("Skip")))
            {
                CommonMethods.driver.FindElement(By.LinkText("Skip")).Click();
                CommonMethods.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(80);
                Thread.Sleep(1000);
                Base.test.Log(Status.Info, "Clicked on Skip button");
            }
        }
        public void SearchForProperty(string sheetName, int datarow)
        {
            ExcelLib.PopulateInCollection(Base.ExcelDataPath, sheetName);
            String SearchItem = ExcelLib.ReadData(datarow, "SearchItem");

            PropertyDetailsPO.SelectMainMenus(mnuOwner, mnuSubProperties);
            barSearch.SendKeys(SearchItem + Keys.Enter);
            //iconSearch.Click();
            CommonMethods.wait(5);
            string ExpectedValue = SearchItem;

            if (CustomMethods.IsElementPresent(By.XPath("//*[@id='main-content']/div/div[1]/div/div[1]/fieldset/div[3]/div[1]/div[1]/div/div/div[2]/div[1]/div[1]/a/h3")))
            {
                string ActualValue = CommonMethods.driver.FindElement(By.XPath("//*[@id='main-content']/div/div[1]/div/div[1]/fieldset/div[3]/div[1]/div[1]/div/div/div[2]/div[1]/div[1]/a/h3")).Text;

                if (ExpectedValue == ActualValue)
                {
                    Base.test.Log(Status.Pass, "Test Passed, Search successfull");
                }
                else
                {
                    Base.test.Log(Status.Fail, "Test Failed, Search Unsuccessfull.Pls check " + CommonMethods.SaveScreenshot());
                }
            }
            else
            {
                Base.test.Log(Status.Fail, "Can not find the seacrched item, Search Unsuccessfull.Pls check " + CommonMethods.SaveScreenshot());
            }
        }
Exemple #15
0
        void FluidCubeAddVelocity(int x, int y, float amountX, float amountY)
        {
            int N     = this.size;
            int index = CustomMethods.IX(x, y);

            this.Vx[index] += amountX;
            this.Vy[index] += amountY;
        }
 private void Apply_Click(object sender, RoutedEventArgs e)
 {
     if (textrun.TextDecorations == null)
     {
         textrun.TextDecorations = new TextDecorationCollection();
     }
     CustomMethods.TextFormat(textrun.Foreground, textrun.Background, textrun.FontFamily, textrun.FontSize, textrun.TextDecorations, textrun.FontStyle, textrun.FontWeight, txtSampleText.Selection.Start.Paragraph.TextAlignment, txtSampleText.FlowDirection, textrun.BaselineAlignment, textpar.LineHeight);
 }
Exemple #17
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     CustomMethods.RegisterFtpFileUploading();
 }
Exemple #18
0
 public TestClass()
 {
     this.homePage                 = new HomePage();
     this.ElemetsPage              = new ElemetsPage();
     this.formsPage                = new FormsPage();
     this.customMethods            = new CustomMethods();
     this.alertFrameWindowsPage    = new AlertFrameWindowsPage();
     this.BookStoreApplicationPage = new BookStoreApplicationPage();
 }
Exemple #19
0
        private void SkinScreenshot_Button_Click(object sender, RoutedEventArgs e)
        {
            string skin = ((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString();

            if (!string.IsNullOrWhiteSpace(skin) && skin == "Create New Skin")
            {
                skin = SkinName_TextBox.Text;
            }
            CustomMethods.SelectScreenshot(skin);
        }
Exemple #20
0
        private void ClrPcker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e)
        {
            Xceed.Wpf.Toolkit.ColorPicker picker = (Xceed.Wpf.Toolkit.ColorPicker)sender;
            string          resource             = picker.Name.Substring(picker.Name.IndexOf("_", StringComparison.Ordinal) + 1);
            SolidColorBrush color = new SolidColorBrush(picker.SelectedColor.Value);

            color.Freeze();
            CustomMethods.ChangeBrushResource(color, resource);
            color = null;
        }
        public void EnterPropertyDetails(string sheetName, int datarow)
        {
            ExcelLib.PopulateInCollection(Base.ExcelDataPath, sheetName);  //PropertyDetails
            //int datarow = 1;
            String PropertyName  = ExcelLib.ReadData(datarow, "PropertyName");
            String PropertyType  = ExcelLib.ReadData(datarow, "PropertyType");
            String SearchAddress = ExcelLib.ReadData(datarow, "SearchAddress");
            String Number        = ExcelLib.ReadData(datarow, "Number");
            String Street        = ExcelLib.ReadData(datarow, "Street");
            String Suburb        = ExcelLib.ReadData(datarow, "Suburb");
            String City          = ExcelLib.ReadData(datarow, "City");
            String PostCode      = ExcelLib.ReadData(datarow, "PostCode");
            String Region        = ExcelLib.ReadData(datarow, "Region");
            String Description   = ExcelLib.ReadData(datarow, "Description");
            String TargetRent    = ExcelLib.ReadData(datarow, "TargetRent");
            String RentType      = ExcelLib.ReadData(datarow, "RentType");
            String LandArea      = ExcelLib.ReadData(datarow, "LandArea");
            String FloorArea     = ExcelLib.ReadData(datarow, "FloorArea");
            String Bedrooms      = ExcelLib.ReadData(datarow, "Bedrooms");
            String Bathrooms     = ExcelLib.ReadData(datarow, "Bathrooms");
            String Carparks      = ExcelLib.ReadData(datarow, "Carparks");
            String YearBuilt     = ExcelLib.ReadData(datarow, "YearBuilt");

            //navigate to Propery details page

            SelectMainMenus(mnuOwner, mnuSubProperties);
            btnAddNewProperty.Click();
            //Enter all property details
            txtPropertyName.SendKeys(PropertyName);
            if (SearchAddress != null)
            {
                ddlSearchAddress.SendKeys(SearchAddress);
                Thread.Sleep(1000);
                ddlSearchAddress.SendKeys(Keys.Down + Keys.Enter);
            }
            else
            {
                var         NoCityPostcode = CommonMethods.driver.FindElements(By.XPath("//*[@id='street_number']"));//Number,City,Postcode fields are having the same ID as locators
                IWebElement txtNumber      = NoCityPostcode.ElementAt(0);
                txtNumber.SendKeys(Number);
                txtStreet.SendKeys(Street);
                CustomMethods.FindElementAndPerformAction("Suburb", Suburb);
                CustomMethods.FindElementAndPerformAction("City", City);
                CustomMethods.FindElementAndPerformAction("PostCode", PostCode);
                txtRegion.SendKeys(Region);
            }

            txaDescription.SendKeys(Description);
            CustomMethods.FindElementAndPerformAction("Rent Amount", TargetRent);
            CustomMethods.FindElementAndPerformAction("Bedrooms", Bedrooms);
            CustomMethods.FindElementAndPerformAction("Bathrooms", Bathrooms);
            CustomMethods.FindElementAndPerformAction("car parks", Carparks);
            CustomMethods.FindElementAndPerformAction("Year Built", YearBuilt);
            btnNext.Click();
        }
Exemple #22
0
        private void LoadSkin_Click(object sender, RoutedEventArgs e)
        {
            //LoadDefault calls ClearImage that deletes the bgimg so first clear the path
            CustomMethods.Imagepath = "";
            CustomMethods.LoadDefault();
            string skin = ((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString();

            CustomMethods.CurrentSkin = @"\" + skin;
            CustomMethods.ReadConfig();
            CustomMethods.SaveCurrentState();
        }
Exemple #23
0
        private void ExportSkin_Click(object sender, RoutedEventArgs e)
        {
            string skinName = SkinName_TextBox.Text;
            //set the name to the user specified name
            string skinFolder = ((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString();

            //TODO: check if skin is null on all function calls
            if (!string.IsNullOrWhiteSpace(skinFolder) && skinFolder != "Create New Skin")
            {
                CustomMethods.ExportSkin(skinFolder, skinName);
            }
        }
 public void CheckContactPageLinks()
 {
     PresidencyProperties.driver.Navigate().GoToUrl(PresidencyProperties.baseUrl + PresidencyProperties.contactUrl);
     if (!CustomMethods.IsElementPresent(By.XPath("//a[contains(@href,'" + PresidencyProperties.emailSupport + "')]")))
     {
         Assert.Fail("support link not present or wrong");
     }
     if (!CustomMethods.IsElementPresent(By.XPath("//a[contains(@href,'" + PresidencyProperties.emailInfo + "')]")))
     {
         Assert.Fail("info link not present or wrong");
     }
 }
Exemple #25
0
 private void SkinsListbox_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.SystemKey.Equals(Key.Delete) || e.Key.Equals(Key.Delete))
     {
         string skin = ((System.Windows.Controls.ListBoxItem)(SkinsListbox.SelectedItem)).Content.ToString();
         if (!string.IsNullOrWhiteSpace(skin) && skin != "Create New Skin")
         {
             CustomMethods.DeleteSkin(skin);
             CustomMethods.GetSkinList();
         }
     }
 }
        public void LinqWhere1()
        {
            Expression <Func <JSArray, object> > expr = array => array.RemoveAt(2);

            var extension = new CustomMethods();
            var js        = expr.CompileToJavascript(
                new JavascriptCompilationOptions(
                    JsCompilationFlags.BodyOnly | JsCompilationFlags.ScopeParameter,
                    new LinqMethods(), extension));

            Assert.AreEqual("array.splice(arg_0, 1)", js);
            Assert.AreEqual(2, ((ConstantExpression)extension.Parameters["arg_0"]).Value);
        }
        public ActionResult State(string SearchValue, string sortOrder, int pid = 0, int cid = 0)
        {
            int        take  = 10;
            int        skip  = take * pid;
            StateModel model = new StateModel();

            model.PageID  = pid;
            model.Current = pid + 1;
            IEnumerable <StateModel> Courses = new List <StateModel>();

            CustomMethods.ValidateRoles("State");
            var Citieslist = new StateBLL {
            }.GetAllState(skip, take);

            if (cid != 0)
            {
                var sortedlist = new StateBLL {
                }.GetAllState(skip, take, cid);
                double count = Convert.ToDouble(sortedlist.Count);
                var    res   = count / take;
                model.Pagecount = (int)Math.Ceiling(res);
                model.StateList = sortedlist.Select(x => new StateModel
                {
                    CountryId   = x.CountryId,
                    CountryName = x.CountryName,
                    StateId     = x.StateId,
                    StateName   = x.StateName,
                    IsActive    = Convert.ToBoolean(x.IsActive)
                }).ToList();
            }
            else
            {
                if (Citieslist != null)
                {
                    double count = Convert.ToDouble(new StateBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    model.Pagecount = (int)Math.Ceiling(res);
                    model.StateList = Citieslist.Select(x => new StateModel
                    {
                        CountryId   = x.CountryId,
                        CountryName = x.CountryName,
                        StateId     = x.StateId,
                        StateName   = x.StateName,
                        IsActive    = Convert.ToBoolean(x.IsActive)
                    }).ToList();
                }
            }

            return(View(model));
        }
        private void AppendAllMethodsToCustomMethodInfo(IEnumerable <MethodInfo> methods)
        {
            foreach (var method in methods)
            {
                CustomMethodInfo customMethodInfo = new CustomMethodInfo
                {
                    Method           = method,
                    InParameterInfo  = method.GetParameters(),
                    OutParameterInfo = method.ReturnParameter
                };

                CustomMethods.Add(customMethodInfo);
            }
        }
        public async Task <List <NewsViewModel> > GetRelatedNewsAsync(int number, List <string> tagIdList, string newsId)
        {
            var newsList = new List <NewsViewModel>();
            int randomRow;
            int recentRandomRow = 0;

            tagIdList.Insert(0, newsId);
            string whereExpression = "NewsId!=@0 and (";

            for (int i = 0; i < tagIdList.Count() - 1; i++)
            {
                whereExpression = whereExpression + @"TagId==@" + (i + 1) + (i + 1 != tagIdList.Count - 1 ? " or " : ")");
            }

            int newsCount = (from n in _context.News.Where(n => n.IsPublish == true && n.PublishDateTime <= DateTime.Now)
                             join t in _context.NewsTags.Where(whereExpression, tagIdList.ToArray())
                             on n.NewsId equals t.NewsId
                             select n).Count();


            for (int i = 0; i < number && i < newsCount; i++)
            {
                randomRow = CustomMethods.RandomNumber(1, newsCount + 1);
                while (recentRandomRow == randomRow)
                {
                    randomRow = CustomMethods.RandomNumber(1, newsCount + 1);
                }

                var news = await(from n in _context.News.Where(n => n.IsPublish == true && n.PublishDateTime <= DateTime.Now).Include(c => c.Comments).Include(l => l.Likes).Include(l => l.Visits)
                                 join t in _context.NewsTags.Where(whereExpression, tagIdList.ToArray())
                                 on n.NewsId equals t.NewsId
                                 select new NewsViewModel
                {
                    Title            = n.Title,
                    Url              = n.Url,
                    NewsId           = n.NewsId,
                    ImageName        = n.ImageName,
                    PublishDateTime  = n.PublishDateTime,
                    NumberOfVisit    = n.Visits.Select(v => v.NumberOfVisit).Sum(),
                    NumberOfLike     = n.Likes.Where(l => l.IsLiked == true).Count(),
                    NumberOfDisLike  = n.Likes.Where(l => l.IsLiked == false).Count(),
                    NumberOfComments = n.Comments.Count(),
                }).Skip(randomRow - 1).Take(1).FirstOrDefaultAsync();

                newsList.Add(news);
                recentRandomRow = randomRow;
            }

            return(newsList);
        }
        public ActionResult City(int pid = 0, int cid = 0)
        {
            int       take  = 10;
            int       skip  = take * pid;
            CityModel model = new CityModel();

            model.PageID  = pid;
            model.Current = pid + 1;
            ViewBag.pid   = pid;
            IEnumerable <CityModel> Courses = new List <CityModel>();

            CustomMethods.ValidateRoles("City");
            var Citieslist = new CityBLL {
            }.GetAllCities(skip, take);

            if (cid != 0)
            {
                var sortedlist = new CityBLL {
                }.GetAllCities(skip, take, cid);
                double count = Convert.ToDouble(sortedlist.Count);
                var    res   = count / take;
                model.Pagecount = (int)Math.Ceiling(res);
                model.CityList  = sortedlist.Select(x => new CityModel
                {
                    CityId   = x.CityId,
                    CityName = x.CityName,
                    StateId  = x.StateId,
                    IsActive = Convert.ToBoolean(x.IsActive)
                }).ToList();
            }
            else
            {
                if (Citieslist != null)
                {
                    double count = Convert.ToDouble(new CityBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    model.Pagecount = (int)Math.Ceiling(res);
                    model.CityList  = Citieslist.Select(x => new CityModel
                    {
                        CityId   = x.CityId,
                        CityName = x.CityName,
                        StateId  = x.StateId,
                        IsActive = Convert.ToBoolean(x.IsActive)
                    }).ToList();
                }
            }
            return(View(model));
        }