示例#1
0
        public IHttpActionResult SaveUser(saus1 user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            bool isDone = UserHelper.SaveUser(user);

            if (!isDone)
            {
                return(InternalServerError());
            }
            return(Ok());
        }
示例#2
0
        public static saus1 GetUser(string UserId)
        {
            var   connection = ApiService.dbConnection;
            saus1 myUser     = null;

            try
            {
                connection.Open();
                myUser = connection.QuerySingleOrDefault <saus1>(qryUser.selectUser, new { UserId });
            }
            catch (Exception) { throw; }
            finally { connection.Close(); }

            return(myUser);
        }
示例#3
0
        public static bool SaveUser(saus1 User)
        {
            var connection = ApiService.dbConnection;
            int afRecCnt   = 0;

            try
            {
                connection.Open();
                int    userCnt = connection.ExecuteScalar <int>(qryUser.selectUserCount, new { UserId = User.UserId });
                string storeProcName;
                if (userCnt <= 0)
                {
                    // set audit values
                    User.WorkStation    = ApiService.HostName;
                    User.CreateBy       = ApiService.UserId;
                    User.CreateDateTime = ApiService.ClientDate;
                    User.UpdateBy       = ApiService.UserId;
                    User.UpdateDateTime = ApiService.ClientDate;

                    storeProcName = qryUser.insertUser;
                }
                else
                {
                    // set audit values
                    User.WorkStation    = ApiService.HostName;
                    User.UpdateBy       = ApiService.UserId;
                    User.UpdateDateTime = ApiService.ClientDate;

                    storeProcName = qryUser.updateUser;
                }

                // execute
                var param = connection.GetStoreProcParams(storeProcName, User);
                afRecCnt = connection.Execute(storeProcName, param, null, null, CommandType.StoredProcedure);
            }
            catch (Exception) { throw; }
            finally { connection.Close(); }

            return(afRecCnt > 0 ? true : false);
        }