Esempio n. 1
0
        // GET: Tags
        public async Task <ActionResult> Index()
        {
            var tags = await db.Tags.ToListAsync();

            var tagsIndexViewModel = ClassTagConverter.ConvertListTagsToListTagIndexViewModel(tags);

            return(View(tagsIndexViewModel));
        }
Esempio n. 2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,name,SlugUrl")] TagEditViewModel tagEditViewModel)
        {
            if (ModelState.IsValid)
            {
                Tag tag = ClassTagConverter.ConvertTagEditViewModelToTag(tagEditViewModel);
                db.Entry(tag).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(tagEditViewModel));
        }
Esempio n. 3
0
        public async Task <ActionResult> Create([Bind(Include = "name,SlugUrl")]  TagCreateViewModel tagCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                Tag tag = ClassTagConverter.ConvertTagCreateViewModelToTag(tagCreateViewModel);
                db.Tags.Add(tag);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(tagCreateViewModel));
        }
Esempio n. 4
0
        // GET: Tags/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tag tag = await db.Tags.FindAsync(id);

            if (tag == null)
            {
                return(HttpNotFound());
            }
            TagDeleteViewModel tagEditViewModel = ClassTagConverter.ConvertTagsToTagDeleteViewModel(tag);

            return(View(tagEditViewModel));
        }