/// <summary> /// handles the operation /// </summary> /// <param name="operationId"></param> /// <returns></returns> public async Task <AlpApiResponse> DoOperation(int operationId) { var response = new AlpApiResponse(); try { _logger.LogDebug(new { action = nameof(DoOperation), operationId }.ToString()); var operation = await _context.Operation.FirstOrDefaultAsync(op => op.OperationId == operationId); if (operation == null) { response.Success = false; response.Message = "A művelet nem található az adatbázisban!"; return(response); } var operationType = (OperationType)operation.OperationType; switch (operationType) { case OperationType.Scrap: response = await _itemService.Scrap(operation.ItemId); break; case OperationType.ChangeOwner: response = await _itemService.ChangeOwner(operation.ItemId, operation.PayLoadId); break; case OperationType.ChangeDepartment: response = await _itemService.ChangeDepartment(operation.ItemId, operation.PayLoadId); break; case OperationType.ChangeOwnerToDepartmentChief: response = await _itemService.ChangeOwnerToDepartmentChief(operation.ItemId); break; } operation.DateOfCompletion = DateTime.Now; } catch (Exception e) { _logger.LogError(new { exception = e, message = e.Message, innerException = e, innerExceptionMessage = e.InnerException?.Message }.ToString()); response.Message = e.Message; response.Success = false; } return(response); }