Esempio n. 1
0
        public async Task <CreateEquipmentResponse> CreateEquipment(CreateEquipmentRequest requestModel)
        {
            //If there's a room, check if the room exists
            if (requestModel.RoomId != null)
            {
                var room = await _room.FindById(requestModel.RoomId.Value);
            }

            //Check if equipment type is valid
            var equipmentType = await _param.FindById(requestModel.EquipmentTypeId);

            if (equipmentType.ParamTypeId != GlobalParams.ParamTypeEquipmentType)
            {
                throw new HttpStatusCodeException(HttpStatusCode.BadRequest, "EquipmentService: EquipmentType is not Valid");
            }

            var equipment = await _repoWrapper.Equipment.CreateAsync(
                CreateEquipmentRequest.NewEquipmentFromRequest(requestModel, equipmentType.TextValue));

            equipment.Code += equipment.EquipmentId;

            equipment = await _repoWrapper.Equipment.UpdateAsync(equipment, equipment.EquipmentId);

            return(CreateEquipmentResponse.CreateFromEquipment(equipment));
        }
Esempio n. 2
0
        private void equipmentCreated(CreateCustomEquipmentOperation operation, HttpResponse httpResponse)
        {
            CreateEquipmentResponse customEquipmentResponse = operation.CustomEquipmentResponse;

            Service.Get <EventDispatcher>().DispatchEvent(new InventoryServiceEvents.EquipmentCreated(customEquipmentResponse.equipmentId));
            Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyAssetsReceived(customEquipmentResponse.assets));
            handleCPResponse(customEquipmentResponse);
        }
Esempio n. 3
0
    protected override void PerformOfflineAction(OfflineDatabase offlineDatabase, IOfflineDefinitionLoader offlineDefinitions)
    {
        Random random = new Random();

        byte[] array = new byte[8];
        random.NextBytes(array);
        long equipmentId = BitConverter.ToInt64(array, 0);

        createEquipment(equipmentId, offlineDatabase, offlineDefinitions);
        CustomEquipmentResponse = new CreateEquipmentResponse
        {
            assets      = offlineDatabase.Read <ClubPenguin.Net.Offline.PlayerAssets>().Assets,
            equipmentId = equipmentId
        };
    }