コード例 #1
0
ファイル: DeptController.cs プロジェクト: OLUWAMUYIWA/Finance
        public async Task <IActionResult> CreateDepartment(string name)
        {
            if (!string.IsNullOrEmpty(name))
            {
                if (await _dService.IsDeptExist(name))
                {
                    var error = new
                    {
                        errors = new { Name = "Department already exists", },
                    };

                    string result = JsonSerializer.Serialize(error);
                    return(BadRequest(result));
                }
                await _dService.CreateDepartment(name, int.Parse(this.User.Claims.First(i => i.Type == "UserID").Value));

                return(Ok());
            }
            return(BadRequest());
        }