public AddItemData AddItemToDB(AddItem ItemAddItemData) { Object PlayerObjectData; TransactionData Tran; AddItemData Result; Result = new AddItemData() { Status = false }; var _db = new PangyaEntities(); var additem = _db.ProcAddItem((int)UID, (int)ItemAddItemData.ItemIffId, (int)ItemAddItemData.Quantity, Compare.IfCompare <byte>(IFFEntry.GetIff.IsSelfDesign(ItemAddItemData.ItemIffId), 1, 0), IFFEntry.GetIff.GetItemTimeFlag(ItemAddItemData.ItemIffId, ItemAddItemData.Day), (int)ItemAddItemData.Day).ToList(); if (additem.Count > 0) { var dbdata = additem.FirstOrDefault(); Tran = new TransactionData() { Types = 2, Index = (uint)dbdata.IDX, TypeID = (uint)dbdata.iffTypeId, PreviousQuan = 0, NewQuan = (uint)dbdata.Quantity, UCC = dbdata.UCC_KEY }; ItemTransaction.Add(Tran); try { switch (ItemAddItemData.ItemIffId.GetItemGroup()) { case IffGroupFlag.ITEM_TYPE_CHARACTER: { PlayerObjectData = new CharacterData(); ((CharacterData)(PlayerObjectData)).Index = (uint)dbdata.IDX; ((CharacterData)(PlayerObjectData)).TypeID = (uint)dbdata.iffTypeId; ((CharacterData)(PlayerObjectData)).HairColour = 0; ((CharacterData)(PlayerObjectData)).GiftFlag = 0; ItemCharacter.CharacterAdd((CharacterData)(PlayerObjectData)); CharacterIndex = (uint)dbdata.IDX; Result = new AddItemData() { Status = true, ItemIndex = ((CharacterData)(PlayerObjectData)).Index, ItemTypeID = ((CharacterData)(PlayerObjectData)).TypeID, ItemOldQty = 1, ItemNewQty = 1, ItemUCCKey = string.Empty, ItemFlag = 0, ItemEndDate = DateTime.MinValue, }; } break; case IffGroupFlag.ITEM_TYPE_AUX: case IffGroupFlag.ITEM_TYPE_PART: case IffGroupFlag.ITEM_TYPE_CLUB: case IffGroupFlag.ITEM_TYPE_BALL: case IffGroupFlag.ITEM_TYPE_USE: case IffGroupFlag.ITEM_TYPE_SKIN: { PlayerObjectData = new WarehouseData(); ((WarehouseData)(PlayerObjectData)).ItemIndex = (uint)dbdata.IDX; ((WarehouseData)(PlayerObjectData)).ItemTypeID = (uint)dbdata.iffTypeId; ((WarehouseData)(PlayerObjectData)).ItemC0 = (ushort)dbdata.Quantity; ((WarehouseData)(PlayerObjectData)).ItemUCCUnique = dbdata.UCC_KEY; ((WarehouseData)(PlayerObjectData)).CreateNewItem(); // Add to inventory list ItemWarehouse.ItemAdd((WarehouseData)(PlayerObjectData)); // Set the result data Result = new AddItemData() { Status = true, ItemIndex = ((WarehouseData)(PlayerObjectData)).ItemIndex, ItemTypeID = ((WarehouseData)(PlayerObjectData)).ItemTypeID, ItemOldQty = 0, ItemNewQty = ItemAddItemData.Quantity, ItemUCCKey = ((WarehouseData)(PlayerObjectData)).ItemUCCUnique, ItemFlag = 0, ItemEndDate = null, }; } break; case IffGroupFlag.ITEM_TYPE_CADDIE: { PlayerObjectData = new CaddieData(); ((CaddieData)(PlayerObjectData)).CaddieIdx = (uint)dbdata.IDX; ((CaddieData)(PlayerObjectData)).CaddieTypeId = (uint)dbdata.iffTypeId; ((CaddieData)(PlayerObjectData)).CaddieDateEnd = (DateTime)dbdata.END_DATE; ((CaddieData)(PlayerObjectData)).CaddieAutoPay = 0; ((CaddieData)(PlayerObjectData)).CaddieType = (byte)dbdata.Flag; // Add caddie to inventory list ItemCaddie.CadieAdd((CaddieData)(PlayerObjectData)); // set the result data Result = new AddItemData() { Status = true, ItemIndex = ((CaddieData)(PlayerObjectData)).CaddieIdx, ItemTypeID = ((CaddieData)(PlayerObjectData)).CaddieTypeId, ItemOldQty = 0, ItemNewQty = 1, ItemUCCKey = string.Empty, ItemFlag = ((CaddieData)(PlayerObjectData)).CaddieType, ItemEndDate = null, }; } break; case IffGroupFlag.ITEM_TYPE_CARD: { PlayerObjectData = new CardData(); ((CardData)(PlayerObjectData)).CardIndex = (uint)dbdata.IDX; ((CardData)(PlayerObjectData)).CardTypeID = (uint)dbdata.iffTypeId; ((CardData)(PlayerObjectData)).CardQuantity = ItemAddItemData.Quantity; ((CardData)(PlayerObjectData)).CardIsValid = 1; ((CardData)(PlayerObjectData)).CardNeedUpdate = false; // ## add to card ItemCard.CardAdd((CardData)(PlayerObjectData)); // set the result data Result = new AddItemData() { Status = true, ItemIndex = ((CardData)(PlayerObjectData)).CardIndex, ItemTypeID = ((CardData)(PlayerObjectData)).CardTypeID, ItemOldQty = 0, ItemNewQty = ((CardData)(PlayerObjectData)).CardQuantity, ItemUCCKey = string.Empty, ItemFlag = 0, ItemEndDate = null, }; } break; case IffGroupFlag.ITEM_TYPE_MASCOT: { PlayerObjectData = new MascotData(); ((MascotData)(PlayerObjectData)).MascotIndex = (uint)dbdata.IDX; ((MascotData)(PlayerObjectData)).MascotTypeID = (uint)dbdata.iffTypeId; ((MascotData)(PlayerObjectData)).MascotMessage = "Pangya !"; ((MascotData)(PlayerObjectData)).MascotIsValid = 1; ((MascotData)(PlayerObjectData)).MascotNeedUpdate = false; ((MascotData)(PlayerObjectData)).MascotEndDate = (DateTime)dbdata.END_DATE; ((MascotData)(PlayerObjectData)).MascotDayToEnd = (ushort)dbdata.END_DATE.DaysBetween(DateTime.Now); // ## add to card ItemMascot.MascotAdd((MascotData)(PlayerObjectData)); // set the result data Result = new AddItemData() { Status = true, ItemIndex = ((MascotData)(PlayerObjectData)).MascotIndex, ItemTypeID = ((MascotData)(PlayerObjectData)).MascotTypeID, ItemOldQty = 0, ItemNewQty = 1, ItemUCCKey = string.Empty, ItemFlag = 4, ItemEndDate = DateTime.Now.AddDays(ItemAddItemData.Day + 1), }; } break; } } catch { } } // ## resulted return(Result); }