public async Task <IActionResult> AddFollowing([FromBody] ProjectToProject entity)
        {
            var trans = await this._projectService.BeginTransactionAsync();

            try
            {
                using (trans)
                {
                    this._projectService.FollowProject(entity.ProjekApiName, entity.KolaborasiApiName);
                    var t = await this._projectService.SaveAsync();

                    var res = new CustomResponse()
                    {
                        errors  = null,
                        message = "Follow Projek Berhasil",
                        title   = "Success",
                        ok      = true
                    };
                    if (t > 0)
                    {
                        this._projectService.Commit(trans);
                        return(Ok(res));
                    }
                    this._projectService.Rollback(trans);
                    res = new CustomResponse()
                    {
                        errors  = null,
                        message = "Follow Projek Gagal",
                        title   = "Warning",
                        ok      = false
                    };
                    return(BadRequest(res));
                }
            }
            catch (Exception ex)
            {
                var res = new CustomResponse()
                {
                    errors = new List <string>()
                    {
                        ex.InnerException.Message
                    },
                    message = ex.Message,
                    title   = "Error",
                    ok      = false
                };
                this._projectService.Rollback(trans);
                return(BadRequest(res));
            }
        }
        public async Task <IActionResult> ApprovalFollower([FromBody] ProjectToProject entity)
        {
            var trans = await this._projectService.BeginTransactionAsync();

            try
            {
                using (trans)
                {
                    var decision = (bool)entity.Approve;
                    this._projectService.ApprovalFollower(entity.Id, decision);
                    var t = await this._projectService.SaveAsync();

                    var res = new CustomResponse()
                    {
                        errors  = null,
                        message = "Approval Follower Projek Berhasil",
                        title   = "Success",
                        ok      = true
                    };
                    if (t > 0)
                    {
                        if (decision == true)
                        {
                            this._projectService.AddScopeApiToClient(entity.Id);
                            t = await this._projectService.SaveConfigContextAsync();

                            if (t > 0)
                            {
                                this._projectService.Commit(trans);
                                return(Ok(res));
                            }
                            this._projectService.Rollback(trans);
                            res = new CustomResponse()
                            {
                                errors  = null,
                                message = "Approval Follower Projek Gagal Tambah Scope",
                                title   = "Warning",
                                ok      = false
                            };
                            return(BadRequest(res));
                        }
                        else
                        {
                            this._projectService.DeleteFollowingScopeApi(entity.ProjekApiName, entity.KolaborasiApiName);
                            t = await this._projectService.SaveConfigContextAsync();

                            if (t > 0)
                            {
                                this._projectService.Commit(trans);
                                return(Ok(res));
                            }
                            this._projectService.Rollback(trans);
                            res = new CustomResponse()
                            {
                                errors  = null,
                                message = "Approval Follower Projek Gagal Hapus Scope",
                                title   = "Warning",
                                ok      = false
                            };
                            return(BadRequest(res));
                        }
                    }
                    this._projectService.Rollback(trans);
                    res = new CustomResponse()
                    {
                        errors  = null,
                        message = "Approval Follower Projek Gagal",
                        title   = "Warning",
                        ok      = false
                    };
                    return(BadRequest(res));
                }
            }
            catch (Exception ex)
            {
                var res = new CustomResponse()
                {
                    errors = new List <string>()
                    {
                        ex.InnerException.Message
                    },
                    message = ex.Message,
                    title   = "Error",
                    ok      = false
                };
                this._projectService.Rollback(trans);
                return(BadRequest(res));
            }
        }
        public async Task <IActionResult> DeleteFollowing([FromBody] ProjectToProject entity)
        {
            var res = new CustomResponse()
            {
                errors  = null,
                message = "Delete Following Projek Berhasil",
                title   = "Success",
                ok      = true
            };
            var t     = -1;
            var trans = await this._projectService.BeginTransactionAsync();

            var configTrans = await this._projectService.BeginTransactionConfigContextAsync();

            try
            {
                using (trans)
                {
                    this._projectService.DeleteFollowingProject(entity.ProjekApiName, entity.KolaborasiApiName);
                    t = await this._projectService.SaveAsync();

                    if (t > 0)
                    {
                        using (configTrans)
                        {
                            this._projectService.DeleteFollowingScopeApi(entity.ProjekApiName, entity.KolaborasiApiName);
                            t = await this._projectService.SaveAsync();

                            //if (t > 0)
                            //{
                            this._projectService.Commit(trans);
                            this._projectService.Commit(configTrans);
                            return(Ok(res));
                            //}
                            //this._projectService.Rollback(trans);
                            //this._projectService.Rollback(configTrans);
                            //res = new CustomResponse()
                            //{
                            //    errors = null,
                            //    message = "Delete Following Gagal pada hapus API",
                            //    title = "Warning",
                            //    ok = false
                            //};
                            //return BadRequest(res);
                        }
                    }
                    this._projectService.Rollback(trans);
                    res = new CustomResponse()
                    {
                        errors  = null,
                        message = "Delete Following Gagal pada hapus relasi",
                        title   = "Warning",
                        ok      = false
                    };
                    return(BadRequest(res));
                }
            }
            catch (Exception ex)
            {
                this._projectService.Rollback(configTrans);
                this._projectService.Rollback(trans);
                res = new CustomResponse()
                {
                    errors = new List <string>()
                    {
                        ex.InnerException.Message
                    },
                    message = ex.Message,
                    title   = "Error",
                    ok      = false
                };
                return(BadRequest(res));
            }
        }