Example #1
0
        public BlogsCategoriesAdminVm GetCategoryById(int id)
        {
            BlogCategory           model = this.Context.BlogCategories.Find(id);
            BlogsCategoriesAdminVm vm    = Mapper.Instance.Map <BlogCategory, BlogsCategoriesAdminVm>(model);

            return(vm);
        }
Example #2
0
        public void EditCategory(BlogsCategoriesAdminVm bm, int id)
        {
            BlogCategory model = this.Context.BlogCategories.Find(id);

            model.Title = bm.Title;
            this.Context.SaveChanges();
        }
 public ActionResult Edit(int id, BlogsCategoriesAdminVm bm)
 {
     if (!this.ModelState.IsValid)
     {
         return(this.View(bm));
     }
     this.service.EditCategory(bm, id);
     return(RedirectToAction("all"));
 }
Example #4
0
        public void AddCategory(BlogsCategoriesAdminVm bm)
        {
            BlogCategory model = new BlogCategory
            {
                Title = bm.Title
            };

            this.Context.BlogCategories.Add(model);
            this.Context.SaveChanges();
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogsCategoriesAdminVm vm = this.service.GetDeletedCategoryById(id);

            if (vm == null)
            {
                return(HttpNotFound());
            }
            return(this.View(vm));
        }
 public ActionResult Add(BlogsCategoriesAdminVm bm)
 {
     if (!this.ModelState.IsValid)
     {
         return(View(bm));
     }
     try
     {
         this.service.AddCategory(bm);
         return(RedirectToAction("All"));
     }
     catch (DbEntityValidationException ex)
     {
         var error = ex.EntityValidationErrors.First().ValidationErrors.First();
         this.ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
         return(this.View());
     }
 }
        public ActionResult Edit(int id)
        {
            BlogsCategoriesAdminVm vm = this.service.GetCategoryById(id);

            return(this.View(vm));
        }