public async Task <IActionResult> UpdateById(long id, ServiceCategoryReceivingDTO serviceCategoryReceivingDTO)
        {
            var response = await _serviceCategoryService.UpdateServiceCategory(id, serviceCategoryReceivingDTO);

            if (response.StatusCode >= 400)
            {
                return(StatusCode(response.StatusCode, response));
            }
            var serviceCategory = ((ApiOkResponse)response).Result;

            return(Ok(serviceCategory));
        }
        public async Task <ActionResult> AddNew(ServiceCategoryReceivingDTO serviceCategoryReceivingDTO)
        {
            var response = await _serviceCategoryService.AddServiceCategory(serviceCategoryReceivingDTO);

            if (response.StatusCode >= 400)
            {
                return(StatusCode(response.StatusCode, response));
            }
            var serviceCategory = ((ApiOkResponse)response).Result;

            return(Ok(serviceCategory));
        }
        public async Task <ApiResponse> AddServiceCategory(ServiceCategoryReceivingDTO serviceCategoryReceivingDTO)
        {
            var serviceCategory      = _mapper.Map <ServiceCategory>(serviceCategoryReceivingDTO);
            var savedserviceCategory = await _serviceCategoryRepo.SaveServiceCategory(serviceCategory);

            if (savedserviceCategory == null)
            {
                return(new ApiResponse(500));
            }
            var serviceCategoryTransferDTO = _mapper.Map <ServiceCategoryTransferDTO>(savedserviceCategory);

            return(new ApiOkResponse(serviceCategoryTransferDTO));
        }
        public async Task <ApiResponse> UpdateServiceCategory(long id, ServiceCategoryReceivingDTO serviceCategoryReceivingDTO)
        {
            var serviceCategoryToUpdate = await _serviceCategoryRepo.FindServiceCategoryById(id);

            if (serviceCategoryToUpdate == null)
            {
                return(new ApiResponse(404));
            }
            serviceCategoryToUpdate.Name              = serviceCategoryReceivingDTO.Name;
            serviceCategoryToUpdate.Description       = serviceCategoryReceivingDTO.Description;
            serviceCategoryToUpdate.ServiceGroupId    = serviceCategoryReceivingDTO.ServiceGroupId;
            serviceCategoryToUpdate.DivisionId        = serviceCategoryReceivingDTO.DivisionId;
            serviceCategoryToUpdate.OperatingEntityId = serviceCategoryReceivingDTO.OperatingEntityId;
            var updatedServiceCategory = await _serviceCategoryRepo.UpdateServiceCategory(serviceCategoryToUpdate);

            if (updatedServiceCategory == null)
            {
                return(new ApiResponse(500));
            }
            var serviceCategoryTransferDTO = _mapper.Map <ServiceCategoryTransferDTO>(updatedServiceCategory);

            return(new ApiOkResponse(serviceCategoryTransferDTO));
        }