public async Task <GetServiceResponse> UpdateServiceStatus(Guid id, UpdateServiceStatusRequest dto)
        {
            var serviceRequest = await _unitOfWork.ServiceRequests.Get(id);

            // validate
            if (serviceRequest is null)
            {
                throw new KeyNotFoundException("Service does not exist.");
            }

            switch (dto.Status)
            {
            case Status.Assigned:
                if (serviceRequest.Status != Status.New)
                {
                    throw new AppException("This status is not allowed for this service state.");
                }
                break;

            case Status.InProgress:
                if (serviceRequest.Status != Status.Assigned)
                {
                    throw new AppException("This status is not allowed for this service state.");
                }
                break;

            case Status.Completed:
                if (serviceRequest.Status != Status.InProgress)
                {
                    throw new AppException("This status is not allowed for this service state.");
                }

                serviceRequest.CompletionDate = DateTime.UtcNow;
                break;

            case Status.Cancelled:
                Status[] possibleStatuses = { Status.New, Status.Assigned };
                if (!possibleStatuses.Contains(serviceRequest.Status))
                {
                    throw new AppException("This status is not allowed for this service state.");
                }
                break;

            default:
                throw new AppException("Incorrect status");
            }

            serviceRequest.Status = dto.Status;

            _unitOfWork.Commit();

            return(_mapper.Map <GetServiceResponse>(serviceRequest));
        }
        public async Task <ActionResult> UpdateServiceStatus(Guid id, [FromBody] UpdateServiceStatusRequest dto)
        {
            if (Account.Role == Role.Customer)
            {
                // customer can only change to cancelled status
                if (dto.Status != Status.Cancelled)
                {
                    return(Unauthorized(new { message = "You are not allowed to set this status." }));
                }
            }

            await _serviceRequestService.UpdateServiceStatus(id, dto);

            return(NoContent());
        }