예제 #1
0
        public Banner GetBanner(int cityId, string zone)
        {
            var banner = context.Banners.FirstOrDefault(b => b.CityId == cityId
                                                            && b.Type.Equals(zone)
                                                            && b.StartDate >= DateTime.Today);

            if (banner == null)
            {
                banner = new Banner
                {
                    CityId = cityId,
                    Text = "Meniu",
                    Title = "Meniu",
                    Type = zone,
                    ImgUrl = "/Content/ads/Default/meniuAd.jpg"
                };
            }

            return banner;
        }
예제 #2
0
파일: AdsService.cs 프로젝트: raiot/uinem
        public void SaveAds(AdsViewModel model)
        {
            int cityId = int.Parse(model.CityId);
            if (locationRepository.CityExists(cityId))
            {
                string cityName = locationRepository.GetCityNameById(cityId);
                string imgUrl= String.Empty;
                if (model.Image != null)
                {
                    ImageService.Image = model.Image;
                    imgUrl = ImageService.SaveAdImage(model.Zone.ToString(), cityName);
                }
                var banner = new Banner
                {
                    CityId = cityId,
                    EndDate = model.ToBeConcluded,
                    StartDate = model.StartsOn,
                    ImgUrl = imgUrl,
                    Type = model.Zone.ToString()
                };

                adsRepository.SaveAd(banner);
            }
        }
예제 #3
0
 public void SaveAd(Banner banner)
 {
     context.Banners.Add(banner);
     context.SaveChanges();
 }