Example #1
0
 private async Task <IActionResult> TryCatchLog(CodeBlockDelegate handler)
 {
     try
     {
         return(await handler());
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         //throw;
         return(StatusCode(500, "Some internal error wich will not be shown here but will be logged"));
     }
 }
Example #2
0
 private async Task <IActionResult> Validation_UserExistance_ModelState(string userId, ModelStateDictionary ModelState, CodeBlockDelegate handler)
 {
     return(await Validation_ModelState_wLog(ModelState, async() => {
         if ((await userManager.FindByIdAsync(userId)) == null)
         {
             return Conflict("User Not found");
         }
         return await handler();
     }));
 }
Example #3
0
 private async Task <IActionResult> Validation_ModelState_wLog(ModelStateDictionary ModelState, CodeBlockDelegate handler)
 {
     if (ModelState.IsValid)
     {
         try
         {
             return(await handler());
         } catch (Exception ex)
         {
             logger.LogError(ex.Message);
             //throw;
             return(StatusCode(500, "Some internal error wich will not be shown here but will be logged"));
         }
     }
     return(ConflictFromModelState(ModelState));
 }