public async Task <ActionResult <CostCenterVM> > CreateCostCenter(CostCenterVM costcenterVM)
        {
            try
            {
                if (costcenterVM == null)
                {
                    return(BadRequest());
                }

                // Add custom model validation error
                CostCenter costcenter = await costcenterRepository.GetCostCenterByname(costcenterVM.CostCenter);

                if (costcenter != null)
                {
                    ModelState.AddModelError("Name", $"CostCenter name: {costcenterVM.CostCenter.Name} already in use");
                    return(BadRequest(ModelState));
                }

                await costcenterRepository.CreateCostCenter(costcenterVM);

                return(CreatedAtAction(nameof(GetCostCenter),
                                       new { id = costcenterVM.CostCenter.Id }, costcenterVM));
            }
            catch (DbUpdateException Ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  Ex.InnerException.Message));
            }
        }