public async Task <IActionResult> Registerdriver([FromBody] RegisterDriverViewModel model) { try { if (CheckExistdriver(model.PhoneNubmber)) { return(Ok(new ResultContract <Driver>() { statuse = false, Data = null, message = "این شماره موبایل قبلا ثبت نام کرده است" })); } else { var driver = model.Adapt <Driver>(); await _context.Drivers.AddAsync(driver); await _context.SaveChangesWithHistoryAsync(HttpContext); return(Ok(new ResultContract <Driver>() { statuse = true, Data = driver, message = "" })); } } catch (Exception ex) { await _logger.LogAsync(HttpContext, ex); return(Ok(new ResultContract <string>() { statuse = false, message = "یک خطای ناشناخته روی داد" })); } }
public async Task Invoke(HttpContext context) { try { await _next(context); } catch (Exception ex) { await _logger.LogAsync(context, ex); context.Response.Redirect("/Error"); } }