Beispiel #1
0
        public string UpdateUser(AdsDTO model)
        {
            string oldImagePath = dao.UpdateUser(model);

            LogDAO.AddLog(General.ProcessType.AdsUpdated, General.TableName.Ads, model.ID);
            return(oldImagePath);
        }
 public ActionResult UpdateAds(AdsDTO model)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.ProcessState = General.Messages.EmptyArea;
     }
     else
     {
         if (model.AdsImage != null)
         {
             HttpPostedFileBase postedFile = model.AdsImage;
             string             ext        = Path.GetExtension(postedFile.FileName);
             if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif")
             {
                 Bitmap userImage    = new Bitmap(postedFile.InputStream);
                 Bitmap resizedImage = new Bitmap(userImage);
                 string uniqueNumber = Guid.NewGuid().ToString();
                 string fileName     = uniqueNumber + postedFile.FileName;
                 resizedImage.Save(Server.MapPath("~/Areas/Admin/Content/AdsImages/" + fileName));
                 model.ImagePath = fileName;
             }
         }
         string oldImagePath = bll.UpdateAds(model);
         if (model.AdsImage != null) // There is new image.
         {
             string oldImageFullPath = Server.MapPath("~/Areas/Admin/Content/AdsImages/" + oldImagePath);
             if (System.IO.File.Exists(oldImageFullPath))
             {
                 System.IO.File.Delete(oldImageFullPath);
             }
         }
         ViewBag.ProcessState = General.Messages.AddSuccess;
     }
     return(View(model));
 }
 public ActionResult AddAds(AdsDTO model)
 {
     if (model.AdsImage == null)
     {
         ViewBag.ProcessState = General.Messages.ImageMissing;
     }
     else if (ModelState.IsValid)
     {
         HttpPostedFileBase postedFile = model.AdsImage;
         string             ext        = Path.GetExtension(postedFile.FileName);
         if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif")
         {
             Bitmap userImage    = new Bitmap(postedFile.InputStream);
             Bitmap resizedImage = new Bitmap(userImage);
             string uniqueNumber = Guid.NewGuid().ToString();
             string fileName     = uniqueNumber + postedFile.FileName;
             resizedImage.Save(Server.MapPath("~/Areas/Admin/Content/AdsImages/" + fileName));
             model.ImagePath = fileName;
             bll.AddAds(model);
             ViewBag.ProcessState = General.Messages.AddSuccess;
             ModelState.Clear();
             model = new AdsDTO();
         }
         else
         {
             ViewBag.ProcessState = General.Messages.ExtensionError;
         }
     }
     else
     {
         ViewBag.ProcessState = General.Messages.EmptyArea;
     }
     return(View(model));
 }
Beispiel #4
0
        public ActionResult UpdateAds(int ID)
        {
            AdsDTO model = new AdsDTO();

            model = bll.GetAdsById(ID);
            return(View(model));
        }
Beispiel #5
0
        public AdsDTO GetAdsById(int iD)
        {
            AdsDTO dto = new AdsDTO();
            Ad     ad  = db.Ads.First(x => x.ID == iD);

            dto.ID        = ad.ID;
            dto.Name      = ad.Name;
            dto.ImagePath = ad.ImagePath;
            dto.Link      = ad.Link;
            dto.Size      = ad.Size;
            return(dto);
        }
        public AdsDTO GetAdsWithID(int ID)
        {
            Ad     ads = db.Ads.First(x => x.ID == ID);
            AdsDTO dto = new AdsDTO();

            dto.ID        = ads.ID;
            dto.Name      = ads.Name;
            dto.Link      = ads.Link;
            dto.ImagePath = ads.ImagePath;
            dto.Imagesize = ads.Size;
            return(dto);
        }
        public void AddAds(AdsDTO model)
        {
            Ad ads = new Ad();

            ads.Name             = model.Name;
            ads.Link             = model.Link;
            ads.ImagePath        = model.ImagePath;
            ads.Size             = model.Imagesize;
            ads.AddDate          = DateTime.Now;
            ads.LastUpdateUserID = UserStatic.UserID;
            ads.LastUpdateDate   = DateTime.Now;
            int ID = dao.AddAds(ads);

            LogDAO.AddLog(General.ProcessType.AdsAdd, General.TableName.Ads, ID);
        }
        public List <AdsDTO> GetAds()
        {
            List <Ad>     list    = db.Ads.Where(x => x.isDeleted == false).OrderBy(x => x.AddDate).ToList();
            List <AdsDTO> dtolist = new List <AdsDTO>();

            foreach (var item in list)
            {
                AdsDTO dto = new AdsDTO();
                dto.ID        = item.ID;
                dto.Name      = item.Name;
                dto.Link      = item.Link;
                dto.ImagePath = item.ImagePath;
                dtolist.Add(dto);
            }
            return(dtolist);
        }
Beispiel #9
0
        public bool AddAds(AdsDTO model)
        {
            Ad ad = new Ad();

            ad.Name             = model.Name;
            ad.ImagePath        = model.ImagePath;
            ad.Link             = model.Link;
            ad.Size             = model.Size;
            ad.AddDate          = DateTime.Now;
            ad.LastUpdateUserID = UserStatic.UserID;
            ad.LastUpdateDate   = DateTime.Now;
            int AdID = dao.AddAds(ad);

            LogDAO.AddLog(General.ProcessType.AdsAdded, General.TableName.Ads, AdID);

            return(true);
        }
Beispiel #10
0
        public List <AdsDTO> GetAdsList()
        {
            List <AdsDTO> adsListDTO = new List <AdsDTO>();
            List <Ad>     adList     = db.Ads.Where(x => x.isDeleted == false).OrderBy(x => x.AddDate).ToList();

            foreach (var item in adList)
            {
                AdsDTO dto = new AdsDTO();
                dto.ID        = item.ID;
                dto.Name      = item.Name;
                dto.ImagePath = item.ImagePath;
                dto.Link      = item.Link;
                dto.Size      = item.Size;
                adsListDTO.Add(dto);
            }

            return(adsListDTO);
        }
 public string UpdateAds(AdsDTO model)
 {
     try
     {
         Ad     ads           = db.Ads.First(x => x.ID == model.ID);
         string oldiamagepath = ads.ImagePath;
         ads.Name = model.Name;
         ads.Link = model.Link;
         if (model.ImagePath != null)
         {
             ads.ImagePath = model.ImagePath;
         }
         ads.Size             = model.Imagesize;
         ads.LastUpdateDate   = DateTime.Now;
         ads.LastUpdateUserID = UserStatic.UserID;
         db.SaveChanges();
         return(oldiamagepath);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ActionResult UpdateAds(int ID)
        {
            AdsDTO dto = bll.GetAdsWithID(ID);

            return(View(dto));
        }
        public ActionResult AddAds()
        {
            AdsDTO dto = new AdsDTO();

            return(View(dto));
        }
Beispiel #14
0
        public ActionResult AddAds()
        {
            AdsDTO model = new AdsDTO();

            return(View(model));
        }