Ejemplo n.º 1
0
        public void Edit(CategoryToEditViewModel categoryToEdit)
        {
            Category category = _dbContext.Categories.FirstOrDefault(c => c.CategoryId == categoryToEdit.CategoryId);

            category.Name = categoryToEdit.Name;
            _dbContext.Entry(category).State = EntityState.Modified;
            _dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "CategoryId,Name")] CategoryToEditViewModel category)
 {
     if (ModelState.IsValid)
     {
         _categoryService.Edit(category);
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Ejemplo n.º 3
0
        // GET: Categories/Edit/5
        public ActionResult Edit(Guid?categoryId)
        {
            if (categoryId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Category category = _categoryService.GetCategoryById(categoryId);

            if (category == null)
            {
                return(HttpNotFound());
            }

            CategoryToEditViewModel categoryToEdit = new CategoryToEditViewModel()
            {
                CategoryId = category.CategoryId,
                Name       = category.Name
            };

            return(View(categoryToEdit));
        }