private Creative InitCreativeForAddToDatabase(RegisterCreativeModel model, string userId)
        {
            Creative creative = model.Creative;

            creative.User = UsersRepository.FindUserById(userId);
            AddCreativeToCounter(creative.User.Id);
            return(creative);
        }
        public void EditCreativeChapter(RegisterCreativeModel model)
        {
            Chapter  chapter  = BuildChapterByRegisterModel(model);
            Creative creative = CreativeRepository.Get(model.creativeId);

            creative.EditDate = DateTime.Now;
            UpdateCreativeAndChapterInDatabase(chapter, creative);
        }
Beispiel #3
0
 public ActionResult EditChapter(RegisterCreativeModel model)
 {
     if (ModelState.IsValid)
     {
         CreativeService.EditCreativeChapter(model);
         return(RedirectToAction("UserPage", "User", new { area = "" }));
     }
     return(View(model));
 }
Beispiel #4
0
        public ActionResult CreateChapter(int?creativeId)
        {
            RegisterCreativeModel model = new RegisterCreativeModel()
            {
                creativeId = creativeId ?? 0
            };

            return(PartialView(model));
        }
        private Chapter InitChapterWithPosition(RegisterCreativeModel model)
        {
            Chapter chapter   = model.Chapter;
            int     lastIndex = GetLastIndexOfChapter(model.Creative);

            chapter.Creative = model.Creative;
            chapter.Number   = lastIndex + 1;
            return(chapter);
        }
Beispiel #6
0
 public ActionResult CreateChapter(RegisterCreativeModel model)
 {
     if (ModelState.IsValid)
     {
         model.Creative = CreativeService.GetCreativeById(model.creativeId);
         CreativeService.AddChapterToCreative(model);
         return(RedirectToAction("UserPage", "User"));
     }
     return(View(model));
 }
Beispiel #7
0
 public ActionResult Create(RegisterCreativeModel creativemodel)
 {
     if (ModelState.IsValid)
     {
         string path = CloudinaryService.UploadCreativeImage(creativemodel.Image);
         creativemodel.Creative.CreativeUri = path;
         CreativeService.AddCreative(creativemodel, User.Identity.GetUserId());
         return(RedirectToAction("Index"));
     }
     return(View(creativemodel));
 }
        public void AddCreative(RegisterCreativeModel creativemodel, string userId)
        {
            Creative creative = InitCreativeForAddToDatabase(creativemodel, userId);
            Chapter  chapter  = creativemodel.Chapter;

            if (chapter.TagsString != null)
            {
                chapter.Tags = GetTags(chapter.TagsString);
            }
            AddCreativeAndChapterToDatabase(creative, chapter);
        }
        public void AddChapterToCreative(RegisterCreativeModel model)
        {
            Creative creative = model.Creative;
            Chapter  chapter  = InitChapterWithPosition(model);

            if (chapter.TagsString != null)
            {
                chapter.Tags = GetTags(chapter.TagsString);
            }
            UpdateDBAfterAddChapterToCreative(creative, chapter);
        }
        private Chapter BuildChapterByRegisterModel(RegisterCreativeModel model)
        {
            Chapter chapter = ChapterRepository.Get(model.chapterId);

            chapter.Text = model.Chapter.Text;
            chapter.Name = model.Chapter.Name;
            if (model.Chapter.TagsString != null)
            {
                chapter.TagsString = model.Chapter.TagsString;
                chapter.Tags       = GetTags(model.Chapter.TagsString);
            }
            return(chapter);
        }