// GET: Tags public async Task <ActionResult> Index() { var tags = await db.Tags.ToListAsync(); var tagsIndexViewModel = ClassTagConverter.ConvertListTagsToListTagIndexViewModel(tags); return(View(tagsIndexViewModel)); }
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)); }
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)); }
// 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)); }