Beispiel #1
0
 public ActionResult Edit([Bind(Include = "ID,Name")] CategoryModel category)
 {
     if (ModelState.IsValid)
     {
         try
         {
             // Checking if already exist a category with same name (case insensitive)
             if (categoryData.CheckIfAlreadyExist(category.Name) == false)
             {
                 ICategoryModel model = category;
                 categoryData.Update(model);
                 return(RedirectToAction("Index"));
             }
             else
             {
                 log.Info("The user tried to add a category that already existed");
                 return(View("AlreadyExists"));
             }
         }
         catch (Exception ex)
         {
             log.Error("Could't edit a category from Database", ex);
             return(View("ErrorRetriveData"));
         }
     }
     else
     {
         log.Error("The model state of the category is invalid");
         return(View("ErrorEdit"));
     }
 }
Beispiel #2
0
 // PUT: api/Categories/5
 public void Put([FromBody] CategoryModel area)
 {
     if (ModelState.IsValid)
     {
         if (categoryData.CheckIfAlreadyExist(area.Name) == false)
         {
             ICategoryModel model = area;
             categoryData.Update(model);
         }
     }
 }
Beispiel #3
0
 // PUT: api/Areas/5
 public void Put([FromBody] AreaModel area)
 {
     if (ModelState.IsValid)
     {
         if (areaData.CheckIfAlreadyExist(area.Name) == false)
         {
             IAreaModel model = area;
             areaData.Update(model);
         }
     }
 }