Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchModel"></param>
 /// <param name="incrementIndex"></param>
 /// <returns></returns>
 public List <FestivalMapModel> SearchDataForMap(MapSearchModel searchModel)
 {
     using (var repo = new filmfestivaldbEntities())
     {
         return(repo.festival_held.Join(repo.festivaldetails, fh => fh.FestivalId, fd => fd.Id, (fh, fd) => new { fh, fd })
                .Where(x => (searchModel.City == null || x.fd.City.Equals(searchModel.City)) &&
                       (searchModel.Country == null || x.fd.Country.Contains(searchModel.Country)) &&
                       (searchModel.FestivalName == null || x.fd.FestivalName.Contains(searchModel.FestivalName)) &&
                       (searchModel.Region == null || x.fd.Region.Equals(searchModel.Region)) &&
                       (searchModel.Month == null || x.fh.FestMonth.Equals(searchModel.Month))
                       ).OrderBy(z => z.fd.Id)
                .Select(y => new FestivalMapModel()
         {
             Country = y.fd.Country,
             FestivalName = y.fd.FestivalName,
             FestUrl = y.fd.FestivalArtUrl,
             Id = y.fd.Id,
             Lat = y.fd.Lat.ToString(),
             Long = y.fd.Lng.ToString()
         })
                .ToList());
     }
     //using (var repo = new filmfestivaldbEntities())
     //{
     //    return repo.festivaldetails.Where(x => (searchModel.City == null || x.City.Equals(searchModel.City))
     //                                           && (searchModel.Country == null || x.Country.Contains(searchModel.Country))
     //                                           && (searchModel.FestivalName == null || x.FestivalName.Contains(searchModel.FestivalName))
     //                                           && (searchModel.Region == null || x.Region.Equals(searchModel.Region))
     //                                           ).OrderBy(z => z.Id)
     //                                           .Select(y => new FestivalMapModel()
     //                                           {
     //                                               Country = y.Country,
     //                                               FestivalName = y.FestivalName,
     //                                               FestUrl = y.FestivalArtUrl,
     //                                               Id = y.Id,
     //                                               Lat = y.Lat.ToString(),
     //                                               Long = y.Lng.ToString()
     //                                           })
     //                                           .ToList();
     //}
 }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            MapSearchModel mapSearchModel = new MapSearchModel();

            if (!string.IsNullOrEmpty(txtboxCity.Text))
            {
                mapSearchModel.City = txtboxCity.Text;
            }
            if (!string.IsNullOrEmpty(txtboxCountry.Text))
            {
                mapSearchModel.Country = txtboxCountry.Text;
            }
            if (!string.IsNullOrEmpty(txtboxName.Text))
            {
                mapSearchModel.FestivalName = txtboxName.Text;
            }
            if (ddlRegion.SelectedValue != "-1")
            {
                mapSearchModel.Region = ddlRegion.SelectedValue;
            }
            if (ddlMonth.SelectedValue != "-1")
            {
                if (ddlMonth.SelectedValue.Equals("TM"))
                {
                    mapSearchModel.Month = DateTime.UtcNow.ToString("MMMM");
                }
                else if (ddlMonth.SelectedValue.Equals("NM"))
                {
                    mapSearchModel.Month = DateTime.UtcNow.AddMonths(1).ToString("MMMM");
                }
                else
                {
                    mapSearchModel.Month = ddlMonth.SelectedValue;
                }
            }
            List <FestivalMapModel> list = exploreFestivalHandler.SearchDataForMap(mapSearchModel);

            rptMarkers.DataSource = null;
            rptMarkers.DataSource = list;
            rptMarkers.DataBind();
        }