public IActionResult SetProjectAccount([FromBody] TokenProjectAccountM model)
 {
     try
     {
         JwtClaimM jwt_claim = _jwtAuth.GetClaims(Request);
         _permission.EnsureProjectManager(jwt_claim.UserId, model.ProjectId);
         _account.EnsureOwner(jwt_claim.UserId, model.AccountId);
         _projectTool.SetAccount(model);
         return(Ok());
     }
     catch (Exception e)
     {
         return(GetError(e));
     }
 }
示例#2
0
        public void SetAccount(TokenProjectAccountM model)
        {
            try
            {
                ProjectTool project_tool = _projectTool.GetOne(pt => pt.ProjectId.Equals(model.ProjectId) && pt.ToolId.Equals(model.ToolId));
                if (project_tool == null)
                {
                    throw NotFound();
                }

                project_tool.AccountId = model.AccountId;
                SaveChanges();
            }
            catch (Exception e)
            {
                throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred!",
                                                                         e, DateTime.Now, "Server", "Service-ProjectTool-SetAccount");
            }
        }