public async Task <IActionResult> UpdateById(long id, ServiceGroupReceivingDTO serviceGroupReceivingDTO)
        {
            var response = await _serviceGroupService.UpdateServiceGroup(id, serviceGroupReceivingDTO);

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

            return(Ok(serviceGroup));
        }
        public async Task <ActionResult> AddNew(ServiceGroupReceivingDTO serviceGroupReceivingDTO)
        {
            var response = await _serviceGroupService.AddServiceGroup(serviceGroupReceivingDTO);

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

            return(Ok(serviceGroup));
        }
Beispiel #3
0
        public async Task <ApiResponse> AddServiceGroup(ServiceGroupReceivingDTO serviceGroupReceivingDTO)
        {
            var serviceGroup      = _mapper.Map <ServiceGroup>(serviceGroupReceivingDTO);
            var savedServiceGroup = await _serviceGroupRepo.SaveServiceGroup(serviceGroup);

            if (savedServiceGroup == null)
            {
                return(new ApiResponse(500));
            }
            var serviceGroupTransferDTO = _mapper.Map <ServiceGroupTransferDTO>(savedServiceGroup);

            return(new ApiOkResponse(serviceGroupTransferDTO));
        }
Beispiel #4
0
        public async Task <ApiResponse> UpdateServiceGroup(long id, ServiceGroupReceivingDTO serviceGroupReceivingDTO)
        {
            var serviceGroupToUpdate = await _serviceGroupRepo.FindServiceGroupById(id);

            if (serviceGroupToUpdate == null)
            {
                return(new ApiResponse(404));
            }
            serviceGroupToUpdate.Name              = serviceGroupReceivingDTO.Name;
            serviceGroupToUpdate.Description       = serviceGroupReceivingDTO.Description;
            serviceGroupToUpdate.OperatingEntityId = serviceGroupReceivingDTO.OperatingEntityId;
            serviceGroupToUpdate.DivisionId        = serviceGroupReceivingDTO.DivisionId;
            var updatedServiceGroup = await _serviceGroupRepo.UpdateServiceGroup(serviceGroupToUpdate);

            if (updatedServiceGroup == null)
            {
                return(new ApiResponse(500));
            }
            var serviceGroupTransferDTO = _mapper.Map <ServiceGroupTransferDTO>(updatedServiceGroup);

            return(new ApiOkResponse(serviceGroupTransferDTO));
        }