Ejemplo n.º 1
0
 public IActionResult AddOrEdit(int id, BrandDto brand)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             brandService.CreateBrand(brand);
         }
         else
         {
             try
             {
                 brandService.UpdateBrand(brand);
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!brandService.BrandExists(brand.Id))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         var brands = brandService.GetAll();
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", brands) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", brand) }));
 }
Ejemplo n.º 2
0
 private bool BrandExists(int id)
 {
     return(_brandService.BrandExists(id));
 }