Example #1
0
        public SetMonetaryRaffleDefinition(MonetaryRaffle raffle, bool delete)
        {
            m_id             = 18241;
            m_strMessageName = "Set Monetary Raffle Definition";

            m_raffle = raffle;
            m_delete = delete;
        }
Example #2
0
        /// <summary>
        /// Parses the response received from the server.
        /// </summary>
        protected override void UnpackResponse()
        {
            base.UnpackResponse();

            // Create the streams we will be reading from.
            using (var responseStream = new MemoryStream(m_responsePayload))
                using (var reader = new BinaryReader(responseStream, Encoding.Unicode))
                {
                    // Try to unpack the data.
                    try
                    {
                        // Seek past return code.
                        reader.BaseStream.Seek(sizeof(int), SeekOrigin.Begin);

                        Raffles = new List <MonetaryRaffle>();

                        // Raffle Count
                        ushort raffleCount = reader.ReadUInt16();

                        // Get all the menus.
                        for (ushort x = 0; x < raffleCount; x++)
                        {
                            MonetaryRaffle raffle = new MonetaryRaffle();

                            raffle.ID          = reader.ReadInt32();
                            raffle.Name        = ReadString(reader);
                            raffle.Description = ReadString(reader);

                            ushort optionCount = reader.ReadUInt16();

                            for (ushort y = 0; y < optionCount; y++)
                            {
                                MonetaryRafflePrizes option = new MonetaryRafflePrizes();

                                option.Value  = ReadDecimal(reader) ?? 0.00m;
                                option.Weight = reader.ReadInt32();

                                raffle.Options.Add(option);
                            }

                            Raffles.Add(raffle);
                        }
                    }
                    catch (EndOfStreamException e)
                    {
                        throw new MessageWrongSizeException(m_strMessageName, e);
                    }
                    catch (Exception e)
                    {
                        throw new ServerException(m_strMessageName, e);
                    }
                }
        }
Example #3
0
        /// <summary>
        /// Updates the sent in monetary raffle. Returns the ID of the monetary raffle that was edited
        /// </summary>
        /// <param name="raffle"></param>
        /// <param name="delete"></param>
        /// <returns></returns>
        public static int SetMonetaryRaffle(MonetaryRaffle raffle, bool delete = false)
        {
            var msg = new SetMonetaryRaffleDefinition(raffle, delete);

            try
            {
                msg.Send();
            }
            catch (ServerCommException ex)
            {
                throw new Exception(msg.MessageName + " Message: " + ex.Message);
            }

            return(msg.Raffle.ID ?? 0);
        }