public async Task <IActionResult> EditDepartment(int Id, string newName) { if (await _dService.IsDeptExist(newName, Id)) { var error = new { errors = new { Name = "Department already exists", }, }; string result = JsonSerializer.Serialize(error); return(BadRequest(result)); } else { await _dService.EditDepartment(Id, newName, int.Parse(this.User.Claims.First(i => i.Type == "UserID").Value)); return(Ok()); } }