public ActionResult Country(int pid = 0, int cid = 0)
        {
            int          take  = 10;
            int          skip  = take * pid;
            CountryModel model = new CountryModel();

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

            CustomMethods.ValidateRoles("Country");
            var countries = new CountryBLL {
            }.GetAllCountries(skip, take);

            if (cid != 0)
            {
                var sortedlist = new CountryBLL {
                }.GetAllCountry(skip, take, cid);
                double count = Convert.ToDouble(sortedlist.Count);
                var    res   = count / take;
                model.Pagecount   = (int)Math.Ceiling(res);
                model.CountryList = sortedlist.Select(x => new CountryModel
                {
                    CountryId   = x.CountryId,
                    CountryName = x.CountryName,
                    IsActive    = Convert.ToBoolean(x.IsActive)
                }).ToList();
            }
            else
            {
                if (countries != null)
                {
                    double count = Convert.ToDouble(new CountryBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    model.Pagecount   = (int)Math.Ceiling(res);
                    model.CountryList = countries.Select(x => new CountryModel
                    {
                        CountryId   = x.CountryId,
                        CountryName = x.CountryName,
                        CountryCode = x.CountryCode,
                        IsActive    = Convert.ToBoolean(x.IsActive)
                    }).ToList();
                }
            }
            return(View(model));
        }
Example #2
0
 public static void BindCountryList <T>(T model)
 {
     try
     {
         var cities = new CountryBLL {
         }.GetAllCountry();
         if (cities != null)
         {
             model.GetType().GetProperty("CountryList").SetValue(model, cities.Select(x => new SelectListItem {
                 Value = x.CountryId.ToString(), Text = x.CountryName
             }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }