예제 #1
0
        public ActionResult Insert(News news, int categoryID, HttpPostedFileBase showcaseImage, IEnumerable <HttpPostedFileBase> detailImages, string tag)
        {
            var sessionControl = HttpContext.Session["UserID"];

            if (ModelState.IsValid)
            {
                User user = _userRepository.GetById(Convert.ToInt32(sessionControl));
                news.UserID     = user.ID;
                news.CategoryID = categoryID;

                if (showcaseImage != null)
                {
                    string fileName  = Guid.NewGuid().ToString().Replace("-", "");
                    string extension = System.IO.Path.GetExtension(Request.Files[0].FileName);
                    string fullPath  = "/External/News/" + fileName + extension;
                    Request.Files[0].SaveAs(Server.MapPath(fullPath));
                    news.ImageStr = fullPath;
                }
                _newsRepository.Insert(news);
                _newsRepository.Save();


                _tagRepository.AddTags(news.ID, tag);

                string multipleImages = System.IO.Path.GetExtension(Request.Files[1].FileName);
                if (multipleImages != "")
                {
                    foreach (var file in detailImages)
                    {
                        if (file.ContentLength > 0)
                        {
                            string fileName  = Guid.NewGuid().ToString().Replace("-", "");
                            string extension = System.IO.Path.GetExtension(Request.Files[1].FileName);
                            string fullPath  = "/External/News/" + fileName + extension;
                            file.SaveAs(Server.MapPath(fullPath));

                            var image = new Image
                            {
                                ImageUrl = fullPath
                            };
                            image.NewsID = news.ID;

                            _imageRepository.Insert(image);
                            _imageRepository.Save();
                        }
                    }
                }
                TempData["Information"] = "News add operation is successful";
                return(RedirectToAction("Index", "News"));
            }

            return(View());
        }
예제 #2
0
        public void ModifyTags(IEnumerable <AppTeamTag> tags)
        {
            List <Tag> tagsAdd    = new List <Tag>();
            List <Tag> tagsModify = new List <Tag>();
            List <Tag> tagsRemove = new List <Tag>();

            foreach (var tag in tags)
            {
                if (tag.Status == tagStatus.Add)
                {
                    tagsAdd.Add(tag.ToTeamTag());
                }
                if (tag.Status == tagStatus.Modify)
                {
                    tagsModify.Add(tag.ToTeamTag());
                }
                if (tag.Status == tagStatus.Delete)
                {
                    tagsRemove.Add(tag.ToTeamTag());
                }
            }
            _tagRepository.AddTags(tagsAdd);
            _tagRepository.ModifyTags(tagsModify);
            _tagRepository.DeleteTags(tagsRemove);
        }
예제 #3
0
        protected override bool AddItem()
        {
            var photoId = (string)Bucket.Instance.For.Item(TagColums.PhotoId).Value;

            if (string.IsNullOrEmpty(photoId))
            {
                throw new Exception("Must provide a valid photo id");
            }

            var tags = (string)Bucket.Instance.For.Item(TagColums.Text).Value;

            if (string.IsNullOrEmpty(tags))
            {
                return(false);
            }

            using (ITagRepository repository = repositoryFactory.CreateTagRepository())
            {
                return(repository.AddTags(photoId, tags));
            }
        }
예제 #4
0
 public async Task <CommonResponse> AddTags(TagModel tagModel)
 {
     return(await _tagrepository.AddTags(tagModel));
 }
 public List <Tag> AddTags(List <Tag> Tags)
 {
     _TagRepository.AddTags(Tags);
     _TagRepository.Save();
     return(Tags);
 }
예제 #6
0
 public void AddTags(MatchCollection extractedHashtags)
 {
     tagRepository.AddTags(extractedHashtags);
 }