コード例 #1
0
ファイル: ClientController.cs プロジェクト: vincomi/OSm
        public ActionResult GetByNumber(string number)
        {
            DapperManager dapp = new DapperManager(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
            try
            {
                ClientModel cln;
                DapperParameters pars = new DapperParameters();
                pars["@phone_number"] = number;
                List<ClientModel> result = dapp.ExecuteProcedure<ClientModel>("up_GetClientByPhoneNumber", pars);

                if (result.Count > 0)
                    cln = result[0];
                else
                    cln = new ClientModel() { Name = "NOT FOUND" };
                return View(cln);
            }
            catch (Exception ex)
            {
                ErrorModel err = new ErrorModel()
                    { Error = ex.Message, StackTrace = ex.StackTrace, Controller = "Client", Method = "GetByNumber", Overload = "ActionResult => string", ID = 1, Note = "" };
                return View("Error");
            }
            finally
            {
                if (dapp != null)
                    dapp.Dispose();
            }
        }