示例#1
0
 public ActionResult UpdateSocialMedia(SocialMediaDTO model)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.ProcessState = General.Messages.EmptyArea;
     }
     else
     {
         if (model.SocialImage != null)
         {
             HttpPostedFileBase postedfile  = model.SocialImage;
             Bitmap             SocialMedia = new Bitmap(postedfile.InputStream);
             string             ext         = Path.GetExtension(postedfile.FileName);
             string             filename    = "";
             if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif")
             {
                 string uniquenumber = Guid.NewGuid().ToString();
                 filename = uniquenumber + postedfile.FileName;
                 SocialMedia.Save(Server.MapPath("~/Areas/Admin/Content/SocialMediaImages/" + filename));
                 model.ImagePath = filename;
             }
         }
         string oldImagePath = bll.UpdateSocialMedia(model);
         if (model.SocialImage != null)
         {
             if (System.IO.File.Exists(Server.MapPath("~/Areas/Admin/Content/SocialMediaImages/" + oldImagePath)))
             {
                 System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Content/SocialMediaImages/" + oldImagePath));
             }
         }
         ViewBag.ProcessState = General.Messages.UpdateSuccess;
     }
     return(View(model));
 }
示例#2
0
        public ActionResult UpdateSocialMedia(int id)
        {
            SocialMediaDTO model = new SocialMediaDTO();

            model = bll.GetSocialMediaDataWithID(id);
            return(View(model));
        }
示例#3
0
        public string UpdateSocialMedia(SocialMediaDTO model)
        {
            string oldImagePath = dao.UpdateSocialMedia(model);

            LogDAO.AddLog(General.ProcessType.SocialMediaUpdate, General.TableName.Social, model.ID);
            return(oldImagePath);
        }
示例#4
0
        public SocialMediaDTO GetSocialMediaDataWithID(int id)
        {
            SocialMediaDTO socialDTO = new SocialMediaDTO();

            socialDTO = dao.GetSocialMediaDataWithID(id);
            return(socialDTO);
        }
示例#5
0
        public ActionResult Update(SocialMediaDTO mediaDTO)
        {
            SocialMediaAccount mediaAccount = socialMediaAccountService.GetByID(mediaDTO.ID);

            mediaAccount.Name = mediaDTO.Name;
            mediaAccount.Url  = mediaDTO.Url;
            socialMediaAccountService.Update(mediaAccount);
            return(Redirect("/SysAdmin/SocialMedia/List"));
        }
        public SocialMediaDTO GetSocialMediaWithID(int ID)
        {
            SocialMedia    socialmedia = db.SocialMedias.First(x => x.ID == ID);
            SocialMediaDTO dto         = new SocialMediaDTO();

            dto.ID        = socialmedia.ID;
            dto.Name      = socialmedia.Name;
            dto.Link      = socialmedia.Link;
            dto.ImagePath = socialmedia.ImagePath;
            return(dto);
        }
        public SocialMediaDTO GetSocialMediaDataWithID(int id)
        {
            SocialMedia    socialMedia    = db.SocialMedias.First(x => x.ID == id);
            SocialMediaDTO socialMediaDTO = new SocialMediaDTO();

            socialMediaDTO.ID        = socialMedia.ID;
            socialMediaDTO.Name      = socialMedia.Name;
            socialMediaDTO.Link      = socialMedia.Link;
            socialMediaDTO.ImagePath = socialMedia.ImagePath;

            return(socialMediaDTO);
        }
示例#8
0
        public ActionResult Update(int id)
        {
            SocialMediaAccount mediaAccount = socialMediaAccountService.GetByID(id);
            SocialMediaDTO     mediaDTO     = new SocialMediaDTO()
            {
                ID   = mediaAccount.ID,
                Name = mediaAccount.Name,
                Url  = mediaAccount.Url,
            };

            return(View(mediaDTO));
        }
示例#9
0
        public bool AddSocialMedia(SocialMediaDTO model)
        {
            SocialMedia socialMedia = new SocialMedia();

            socialMedia.Name             = model.Name;
            socialMedia.ImagePath        = model.ImagePath;
            socialMedia.Link             = model.Link;
            socialMedia.AddDate          = DateTime.Now;
            socialMedia.LastUpdateDate   = DateTime.Now;
            socialMedia.LastUpdateUserID = UserStatic.UserID;
            int ID = dao.AddSocialMedia(socialMedia);

            LogDAO.AddLog(General.ProcessType.SocialMediaAdd, General.TableName.Social, ID);
            return(true);
        }
        public List <SocialMediaDTO> GetSocialMedias()
        {
            List <SocialMedia>    list    = db.SocialMedias.Where(x => x.isDeleted == false).ToList();
            List <SocialMediaDTO> dtolist = new List <SocialMediaDTO>();

            foreach (var item in list)
            {
                SocialMediaDTO dto = new SocialMediaDTO();
                dto.Name      = item.Name;
                dto.Link      = item.Link;
                dto.ImagePath = item.ImagePath;
                dto.ID        = item.ID;
                dtolist.Add(dto);
            }
            return(dtolist);
        }
        public List <SocialMediaDTO> GetSocialMediaData()
        {
            List <SocialMediaDTO> socialDTOList = new List <SocialMediaDTO>();
            List <SocialMedia>    socialList    = db.SocialMedias.Where(x => x.isDeleted == false).OrderBy(x => x.AddDate).ToList();

            foreach (var item in socialList)
            {
                SocialMediaDTO dto = new SocialMediaDTO();
                dto.ID        = item.ID;
                dto.Name      = item.Name;
                dto.ImagePath = item.ImagePath;
                dto.Link      = item.Link;
                socialDTOList.Add(dto);
            }

            return(socialDTOList);
        }
示例#12
0
        public ActionResult AddSocialMedia(SocialMediaDTO model)
        {
            if (model.SocialImage == null)
            {
                ViewBag.ProcessState = General.Messages.ImageMissing;
            }
            else if (ModelState.IsValid)
            {
                HttpPostedFileBase postedFile = model.SocialImage;
                string             ext        = Path.GetExtension(postedFile.FileName);
                string             fileName   = string.Empty;
                if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif")
                {
                    Bitmap socialMedia  = new Bitmap(postedFile.InputStream);
                    string uniqueNumber = Guid.NewGuid().ToString();
                    fileName = uniqueNumber + postedFile.FileName;
                    socialMedia.Save(Server.MapPath("~/Areas/Admin/Content/socialmedia/" + fileName));
                    model.ImagePath = fileName;

                    if (bll.AddSocialMedia(model))
                    {
                        ViewBag.ProcessState = General.Messages.AddSuccess;
                        ModelState.Clear();
                    }
                    else
                    {
                        ViewBag.ProcessState = General.Messages.GeneralError;
                    }
                }
                else
                {
                    ViewBag.ProcessState = General.Messages.ExtensionError;
                }
            }
            else
            {
                ViewBag.ProcessState = General.Messages.EmptyArea;
            }

            SocialMediaDTO newModel = new SocialMediaDTO();

            return(View(newModel));
        }
 public string UpdateSocialMedia(SocialMediaDTO model)
 {
     try
     {
         SocialMedia social       = db.SocialMedias.First(x => x.ID == model.ID);
         string      oldImagePath = social.ImagePath;
         social.Name = model.Name;
         social.Link = model.Link;
         if (model.ImagePath != null)
         {
             social.ImagePath = model.ImagePath;
         }
         social.LastUpdateDate   = DateTime.Now;
         social.LastUpdateUserID = UserStatic.UserID;
         db.SaveChanges();
         return(oldImagePath);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#14
0
        // GET: Admin/SocialMedia

        public ActionResult AddSocialMedia()
        {
            SocialMediaDTO model = new SocialMediaDTO();

            return(View(model));
        }
示例#15
0
        public SocialMediaDTO GetSocialMediaWithID(int ID)
        {
            SocialMediaDTO dto = dao.GetSocialMediaWithID(ID);

            return(dto);
        }
示例#16
0
        public ActionResult UpdateSocialMedia(int ID)
        {
            SocialMediaDTO dto = bll.GetSocialMediaWithID(ID);

            return(View(dto));
        }
示例#17
0
        // GET: Admin/SocialMedia
        public ActionResult AddSocialMedia()
        {
            SocialMediaDTO dto = new SocialMediaDTO();

            return(View(dto));
        }