예제 #1
0
 public ActionResult Index([Bind("searchValue,searchOld")] VMSearchClient payload)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState.GetErrorMessages()));
         }
         if (string.IsNullOrEmpty(payload.searchValue) || string.IsNullOrWhiteSpace(payload.searchValue))
         {
             return(View(_instructorService.GetAll()));
         }
         else
         {
             ViewData["searchOld"] = payload.searchValue;
             return(View(_instructorService.GetInstructorByNameOrRGOrCPF(payload.searchValue)));
         }
     }
     catch (CustomHttpException ex)
     {
         TempData["_mensagem"] = new VMMessages()
         {
             Css  = "alert alert-danger",
             Text = ex.ErrorMessage
         };
     }
     catch (Exception ex)
     {
         _logger.Log(LogLevel.Error, ex.Message);
         TempData["_mensagem"] = new VMMessages()
         {
             Css  = "alert alert-danger",
             Text = "Um erro insperado ocorreu"
         };
     }
     return(View(_instructorService.GetAll()));
 }