Example #1
0
        public ActionResult EditTags()
        {
            AppUser       currentUser = repo.GetById(User.Identity.GetUserId <int>());
            EditTagsModel editTags    = new EditTagsModel {
                UserTags = currentUser.Tags,
                AllTags  = tagRepo.GetAllTags()
            };

            return(View(editTags));
        }
        public void ToEditTags(EditTagsModel model)
        {
            // распределяет по коллекциям для добавления (если объекта еще не существует)
            // или удаления (если объект уже существует) тэгов
            FirstStage(model.SelectTags);

            var pictureId = new PictureFindDao().GetPictureIdByPictureUrl(model.PictureUrl);

            var pictureTagsForPicture = new PictureTagFindDao().GetPictureTagsForPicture(pictureId);

            // Удаление ненужных тэгов
            new PictureTagDeleteDao().DeleteListOfPictureTags(GetPictureTagsForDelete(pictureTagsForPicture));

            // Создание необходимых тэгов
            new PictureTagCreateDao().CreateTagsForPicture(pictureId, GetPictureTagsForCreate(pictureTagsForPicture));
        }
        public ActionResult EditTags(EditTagsModel editTagsModel)
        {
            // Security
            if (editTagsModel == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                new PictureTagEditProcessor().ToEditTags(editTagsModel);

                return(RedirectToAction("MyPictures"));
            }

            return(View(editTagsModel));
        }