public ResponseMyAccountDelete DelMyAccount([FromBody] RequestMyAccountDelete request)
 {
     try
     {
         MyAccountBLL bll = new MyAccountBLL();
         return(bll.DelMyAccount(request));
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(
                   Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Example #2
0
        public ResponseMyAccountDelete DelMyAccount(RequestMyAccountDelete request)
        {
            ResponseMyAccountDelete response = new ResponseMyAccountDelete();

            using (cnn = GetConnection())
            {
                var ts = cnn.BeginTransaction();
                try
                {
                    var user = this.UserInfoGetButAccount(request.Token, ts);
                    //string sql = "select * from TKS_FAS_MyAccount where id=@Id";
                    //var myAccount = cnn.QueryFirstOrDefault<TKS_FAS_MyAccount>(sql, new { Id = request.Data.Id }, ts);



                    string sql = @"select * from TKS_FAS_AccountInfo where id=@AccountId";

                    var account = cnn.QueryFirstOrDefault <TKS_FAS_AccountInfo>(sql, new { AccountId = request.Data.Id }, ts);
                    if (account == null)
                    {
                        throw new NormalException("账套不存在");
                    }


                    cnn.Execute("delete from TKS_FAS_MyAccount where AccountId=@AccountId and NodeId=@NodeId", new
                    {
                        AccountId = account.Id,
                        NodeId    = user.Node.CreditCode
                    }, ts);

                    cnn.Execute(@"update TKS_FAS_AccountInfo set IsInvitation=0 ,
                                   InvitationQYCode='',
                                    InvitationQYName=''
                                where id=@Id",
                                new
                    {
                        Id = account.Id
                    }, ts);

                    ts.Commit();
                    response.IsSuccess = true;
                    response.Message   = "取消成功";
                    return(response);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    return(this.DealException(response, ex) as ResponseMyAccountDelete);
                }
            }
        }