示例#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"));
     }
 }
示例#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();
     }));
 }
示例#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));
 }