コード例 #1
0
 public ActionResult EditAdvertisement(string Id)
 {
     Api.Ads.Ads apiobjNews = new Api.Ads.Ads();
     Domain.Socioboard.Domain.Ads ObjAdvertise = (Domain.Socioboard.Domain.Ads)(new JavaScriptSerializer().Deserialize(apiobjNews.GetAdsdetailsById(Id), typeof(Domain.Socioboard.Domain.Ads)));
     Session["AdvertiseToToUpdate"] = ObjAdvertise;
     return(View(ObjAdvertise));
 }
コード例 #2
0
        public ActionResult AddAdvertisement(string Advertisement, string AdsExpiryDate, string Status, string AdsImageUrl)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }

            Domain.Socioboard.Domain.Ads objAds = new Domain.Socioboard.Domain.Ads();
            objAds.Id           = Guid.NewGuid();
            objAds.Advertisment = Advertisement;
            objAds.EntryDate    = DateTime.Now;
            objAds.ExpiryDate   = Convert.ToDateTime(AdsExpiryDate);
            objAds.Status       = bool.Parse(Status);
            var    fi   = Request.Files["advsfile"];
            string file = string.Empty;

            if (Request.Files.Count > 0)
            {
                if (fi != null)
                {
                    var path = Server.MapPath("~/Themes/" + System.Configuration.ConfigurationManager.AppSettings["domain"] + "/Contents/img/admin/AdvertiseImage");

                    // var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"]+"Contents/img/upload";
                    file = path + "/" + fi.FileName;
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    fi.SaveAs(file);
                    path            = path + "/" + fi.FileName;
                    objAds.ImageUrl = path.ToString();
                }
            }
            else
            {
                var path = Server.MapPath("~/Themes/" + System.Configuration.ConfigurationManager.AppSettings["domain"] + "/Contents/img/admin/AdvertiseImage");

                file            = path + "/" + AdsImageUrl;
                objAds.ImageUrl = file;
            }



            string ObjAdvertisement = (new JavaScriptSerializer().Serialize(objAds));

            Api.Ads.Ads apiobjNews     = new Api.Ads.Ads();
            string      NewsAdsMessage = (string)(new JavaScriptSerializer().Deserialize(apiobjNews.AddAdvertisement(ObjAdvertisement, Advertisement), typeof(string)));

            return(Content(NewsAdsMessage));
        }
コード例 #3
0
 public string GetAdsdetailsById(string AdsId)
 {
     try
     {
         Domain.Socioboard.Domain.Ads objAds = objAdsRepo.getAdsDetailsbyId(Guid.Parse(AdsId));
         return(new JavaScriptSerializer().Serialize(objAds));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
コード例 #4
0
 public string UpdateAdvertisement(string ObjAdvertisement)
 {
     try
     {
         Domain.Socioboard.Domain.Ads ObjAds = (Domain.Socioboard.Domain.Ads)(new JavaScriptSerializer().Deserialize(ObjAdvertisement, typeof(Domain.Socioboard.Domain.Ads)));
         objAdsRepo.UpdateAds(ObjAds);
         return(new JavaScriptSerializer().Serialize("Updated Successfully"));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(null);
     }
 }
コード例 #5
0
        public ActionResult AddAdvertisement(string Advertisement, string AdsExpiryDate, string Status, string AdsImageUrl)
        {
            Domain.Socioboard.Domain.Ads objAds = new Domain.Socioboard.Domain.Ads();
            objAds.Id = Guid.NewGuid();
            objAds.Advertisment = Advertisement;
            objAds.EntryDate = DateTime.Now;
            objAds.ExpiryDate = Convert.ToDateTime(AdsExpiryDate);
            objAds.Status = bool.Parse(Status);
            var fi = Request.Files["advsfile"];
            string file = string.Empty;
            if (Request.Files.Count > 0)
            {
                if (fi != null)
                {
                    var path = Server.MapPath("~/Themes/" + System.Configuration.ConfigurationManager.AppSettings["domain"] + "/Contents/img/admin/AdvertiseImage");

                    // var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"]+"Contents/img/upload";
                    file = path + "/" + fi.FileName;
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    fi.SaveAs(file);
                    path = path + "/" + fi.FileName;
                    objAds.ImageUrl = path.ToString();
                }
            }
            else
            {
                var path = Server.MapPath("~/Themes/" + System.Configuration.ConfigurationManager.AppSettings["domain"] + "/Contents/img/admin/AdvertiseImage");

                file = path + "/" + AdsImageUrl;
                objAds.ImageUrl = file;
            }



            string ObjAdvertisement = (new JavaScriptSerializer().Serialize(objAds));
            Api.Ads.Ads apiobjNews = new Api.Ads.Ads();
            string NewsAdsMessage = (string)(new JavaScriptSerializer().Deserialize(apiobjNews.AddAdvertisement(ObjAdvertisement, Advertisement), typeof(string)));
            return Content(NewsAdsMessage);
        }
コード例 #6
0
        public ActionResult EditAdvertisement(string Id)
        {
            if (Session["User"] != null)
            {
                Domain.Socioboard.Domain.User _User = (Domain.Socioboard.Domain.User)Session["User"];
                if (_User.UserType != "SuperAdmin")
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }

            Api.Ads.Ads apiobjNews = new Api.Ads.Ads();
            Domain.Socioboard.Domain.Ads ObjAdvertise = (Domain.Socioboard.Domain.Ads)(new JavaScriptSerializer().Deserialize(apiobjNews.GetAdsdetailsById(Id), typeof(Domain.Socioboard.Domain.Ads)));
            Session["AdvertiseToToUpdate"] = ObjAdvertise;
            return(View(ObjAdvertise));
        }
コード例 #7
0
 public string AddAdvertisement(string ObjAdvertisement, string Advertise)
 {
     try
     {
         if (objAdsRepo.checkAdsExists(Advertise))
         {
             Domain.Socioboard.Domain.Ads ObjAds = (Domain.Socioboard.Domain.Ads)(new JavaScriptSerializer().Deserialize(ObjAdvertisement, typeof(Domain.Socioboard.Domain.Ads)));
             objAdsRepo.UpdateAds(ObjAds);
             return(new JavaScriptSerializer().Serialize("Success"));
         }
         else
         {
             Domain.Socioboard.Domain.Ads ObjAds = (Domain.Socioboard.Domain.Ads)(new JavaScriptSerializer().Deserialize(ObjAdvertisement, typeof(Domain.Socioboard.Domain.Ads)));
             objAdsRepo.AddAds(ObjAds);
             return(new JavaScriptSerializer().Serialize("Success"));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(null);
     }
 }