Example #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            
            selectedCategoryImageUri = NavigationContext.QueryString["selectedCategoryImageUri"];
            selectedCategory = NavigationContext.QueryString["selectedCategory"];

            BannerTextBlock.Text = selectedCategory;
            Uri uri = new Uri(selectedCategoryImageUri, UriKind.Relative);
            BitmapImage imgSource = new BitmapImage(uri);
            CategoryImageBox.Source = imgSource;


            
           
           
            //Load the gift items
            var giftData = retrieveGiftData(selectedCategory, "");

            if(giftData.Any() == false)
            {   
                Gift emptyGift = new Gift();
                emptyGift.GiftName = "No "+selectedCategory+" gifts found!";
                emptyGift.GiftImageUri = "../Images/VioletTulip.jpg";

                giftData = new[] {emptyGift};
            }

            giftListBox.ItemsSource = giftData;

        }
Example #2
0
 public static Gift GetGiftByGiftID(int GiftID)
 {
     Gift gift = new Gift();
     SqlGiftProvider sqlGiftProvider = new SqlGiftProvider();
     gift = sqlGiftProvider.GetGiftByGiftID(GiftID);
     return gift;
 }
Example #3
0
 static void Main(string[] args)
 {
     Gift gift = new Gift();
     Candy candy = new Candy("jelly",0.02,0.012,Filling.jelly);
     gift.Add(candy);
     Cookie cookie = new Cookie("bicquit",  0.1, 0.08,Filling.condensedMilk,Covering.chocolate);
     gift.Add(cookie);
     Jujube jujube = new Jujube("jujube", 0.012, 0.017);
     gift.Add(jujube);
     Chocolate chocolate = new Chocolate("alyonka", 0.1, 0.09) ;
     gift.Add(chocolate);
     Jujube jujube1 = new Jujube(null, 0.012, 0.007);
     gift.Add(jujube1);
     Console.WriteLine("In gift is:");
     gift.ShowGift();
     Console.WriteLine("\nWeight of gift: " + gift.OverallWeight);
     gift.SortByName();
     Console.WriteLine("\nSorted confections: ");
     gift.ShowGift();
     double moreThan=0;
     double lessThan=0.07;
     Console.WriteLine("\nFind elements with {0} - {1} sugar:",moreThan,lessThan);
     ICollection<IGiftItem> find = gift.SearchBySugar(moreThan, lessThan).ToList<IGiftItem>();
     foreach (var i in find) i.ShowElement();
     
 }
        public Gift ParceCandyToGift(string[] sweet, Gift gift)
        {
            try
            {

                switch (sweet[1])
                {
                    case "Chocolate Candy":
                        {

                            gift.AddSweet(new ChocolateCandy(sweet[3], sweet[5], int.Parse(sweet[7]), double.Parse(sweet[9]),
                                sweet[11], sweet[13]));

                            break;
                        }
                    case "Caramel":
                        {
                            gift.AddSweet(new Caramel(sweet[3], sweet[5], int.Parse(sweet[7]), double.Parse(sweet[9]),
                                sweet[11], sweet[13], sweet[15]));

                            break;
                        }
                    case "Iris":
                        {
                            gift.AddSweet(new Iris(sweet[3], sweet[5], int.Parse(sweet[7]), double.Parse(sweet[9]),
                                sweet[11], sweet[13]));

                            break;
                        }
                    case "JellyBean":
                        {
                            gift.AddSweet(new JellyBean(sweet[3], sweet[5], int.Parse(sweet[7]), double.Parse(sweet[9]),
                                sweet[11], sweet[13]));

                            break;
                        }
                    case "Grilyazh":
                        {
                            gift.AddSweet(new Roasting(sweet[3], sweet[5], int.Parse(sweet[7]), double.Parse(sweet[9]),
                                sweet[11]));

                            break;
                        }
                }
            }

                //my exception
            catch (TooMuchParametersException ex)
            {
                Console.WriteLine("Exception occured" + ex);
            }
            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine("Exception occured" + ex);
            }
            return gift;
        }
 public override TimeSpan GetNElement(int N)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     Gift gift = new Gift();
     myDictionary.TryGetValue(N, out gift);
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
Example #6
0
 public override TimeSpan GetNElement(int N)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     Gift gift = new Gift();
     gift = myStack.ToArray()[N-1];
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
 public override TimeSpan RemoveNElement(int N)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     Gift gift = new Gift();
     myDictionary.Remove(N);
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
 public override TimeSpan Init(Gift gift)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     for (int i = 1; i <= 1000; i++)
     {
         myDictionary.Add(i, gift);
     }
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
Example #9
0
 public override TimeSpan Init(Gift gift)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     for (int i = 1; i <= 1000; i++)
     {
         myStack.Push(gift);
     }
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
        public Gift ReadDataToGift(string filename)
        {
            Gift gift = new Gift();
            string[] data = { };
            data = ReadData(filename);
            int count = data.Count()-1;
            for (int i = 0; i < count; i++)
            {
                gift = ParceCandyToGift(Regex.Split(data[i], "\""), gift);
            }

            return gift;
        }
 public override TimeSpan Init(Gift gift)
 {
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     myLinkedList.AddFirst(gift);
     for (int i = 1; i <= 1000; i++)
     {
         myLinkedList.AddLast(gift);
     }
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
        public override TimeSpan Init(Gift gift)
        {
            Stopwatch sWatch = new Stopwatch();
            sWatch.Start();
            for (int i = 0; i <= 1000; i++)
            {
                myArrayList.Add(gift);
            }
            sWatch.Stop();
            TimeSpan timeSpan = sWatch.Elapsed;

            return timeSpan;
        }
Example #13
0
    public void SetGift(Gift gift, int numDay)
    {
        this.gift = gift;

        if (gift.type.Equals(Gift.GiftType.Box))
            SetDescription();
        else
            SetDescription(gift.val1);

        SetNumDay(numDay);

        SetImage();

        SetMain();
    }
 public override TimeSpan GetNElement(int N)
 {
     int i = 1;
     Stopwatch sWatch = new Stopwatch();
     sWatch.Start();
     Gift gift = new Gift();
     foreach (DictionaryEntry key in myHashtable)
     {
         if (i == N)
         {
             gift = (Gift) key.Value;
             break;
         }
         i++;
     }
     sWatch.Stop();
     TimeSpan timeSpan = sWatch.Elapsed;
     return timeSpan;
 }
Example #15
0
    // Use this for initialization
    void Awake()
    {
        libraryMenu = GameObject.FindObjectOfType<LibraryMenu>();

        TextAsset xmlAsset = Resources.Load("Info/DailyGift") as TextAsset;

        XmlDocument xmlDoc = new XmlDocument();
        if (xmlAsset)
            xmlDoc.LoadXml(xmlAsset.text);

        foreach (XmlNode node in xmlDoc.ChildNodes[0])
        {
            Gift gift = new Gift();

           if(node.Attributes["type"].Value.Equals("box"))
           {
                gift.type = Gift.GiftType.Box;
                gift.val1 = int.Parse(node.Attributes["val1"].Value);
                gift.val2 = int.Parse(node.Attributes["val2"].Value);
                gift.val3 = int.Parse(node.Attributes["val3"].Value);
                gift.val4 = int.Parse(node.Attributes["val4"].Value);
                gift.val5 = int.Parse(node.Attributes["val5"].Value);
            }
           else
            {
                switch(node.Attributes["type"].Value)
                {
                    case "money": gift.type = Gift.GiftType.Money; break;
                    case "booster1": gift.type = Gift.GiftType.Booster1; break;
                    case "booster2": gift.type = Gift.GiftType.Booster2; break;
                    case "booster3": gift.type = Gift.GiftType.Booster3; break;
                    case "bonus": gift.type = Gift.GiftType.Bonus; break;
                }
                gift.val1 = int.Parse(node.Attributes["val"].Value);

            }
            gift.isMain = bool.Parse(node.Attributes["isMain"].Value);
            obj.Add(gift);
        }
    }
Example #16
0
        static Core()
        {
            if (!File.Exists("Data.xml"))
            {
                var _data = new XDocument();
                _sweetGift = new XElement("SweetGift");
                _data.Add(_sweetGift);
                _data.Save("Data.xml");
            }

            _data = XDocument.Load("Data.xml");
            if (_data.Element("SweetGift") == null)
            {
                _sweetGift = new XElement("SweetGift");
                _data.Add(_sweetGift);
            }
            else
            {
                _sweetGift = _data.Element("SweetGift");
            }

            Gift = new Gift();
            FillData();
        }
Example #17
0
        public override TimeSpan RemoveNElement(int N)
        {
            Stopwatch sWatch = new Stopwatch();

            Gift gift = new Gift();
            Stack<Gift> tmpStack = new Stack<Gift>();
            sWatch.Start();
            int count = myStack.Count - N;

            for (int i = 0; i < count; i++)
            {
                tmpStack.Push(myStack.Pop());
            }
            tmpStack.Pop();
            count = tmpStack.Count;
            for (int i = 0; i < count; i++)
            {
                tmpStack.Push(tmpStack.Pop());
            }
            myStack.Pop();
            sWatch.Stop();
            TimeSpan timeSpan = sWatch.Elapsed;
            return timeSpan;
        }
Example #18
0
 public static void Create(Gift gift)
 {
 }
Example #19
0
        static void Main(string[] args)
        {
            User[] users = new User[2];
            users[0].name = "Swatar";
            users[0].age  = 18;
            users[1].name = "MrWeebeez";
            users[1].age  = 18;

            var clock1  = new Clock(ClockModel.G_shock, "China", "1 year", 59.99F, 20);
            var clock2  = new Clock(ClockModel.ApplWtc, "USA", "5 year", 399.99F, 30);
            var clock3  = new Clock(ClockModel.Mi_Band, "China", "4 year", 149.99F, 40);
            var flower1 = new Flowers(Flower.Rose, "Вкусно", "Italy", "5 days", 5, 4);
            var Lakomka = new Cake("Вкусно", "Belarus", "5 days", 8, 50, 20, 50, 10, 20, 40, 50);
            var gift    = new Gift();


            var products = new Product[5];

            products[0] = clock1;
            products[1] = clock2;
            products[2] = clock3;
            products[3] = flower1;
            products[4] = Lakomka;

            Int32          varint = 0;
            ConsoleKeyInfo info;

            while (varint == 0)
            {
                Console.WriteLine(
                    "Введите функцию, которую хотите выполнить:" +
                    "\n1)Показать информацию о товарах\n2)Чтобы что-нибудь скушать\n3)Кинуть часы(class)\n4)Кинуть часы(interface)\n" +
                    "5)G_shock - это часы?\n6)Типы наших товаров\n7)Работа с подарком на Новый Год\n8)Работа с Экзепшионами\n9)Тест\n0)Выход из программы");

                Console.WriteLine(new string('_', 100));
                info = Console.ReadKey(true);
                if (info.KeyChar == '1')
                {
                    Console.Clear();
                    try
                    {
                        foreach (Product product in products)
                        {
                            product.Info();
                        }
                    }
                    catch
                    {
                        throw new ArgumentOutOfRangeException("Выход за пределы массива");
                    }
                }

                if (info.KeyChar == '2')
                {
                    Console.Clear();
                    Console.WriteLine("1-Часы\n2-Торт\n3-Цветок");
                    Console.WriteLine(new string('_', 100));
                    info = Console.ReadKey(true);
                    if (info.KeyChar == '1')
                    {
                        Console.Clear();
                        clock1.Eat();
                    }
                    if (info.KeyChar == '2')
                    {
                        Console.Clear();
                        Lakomka.Eat();
                    }
                    if (info.KeyChar == '3')
                    {
                        ComAliasNameAttribute a = new ComAliasNameAttribute(alias:);
                    }
                }


                if (info.KeyChar == '4')
                {
                    Console.Clear();
                    ((Ieat)clock2).Throw();
                }

                if (info.KeyChar == '5')
                {
                    Console.Clear();
                    Console.WriteLine("Являются ли часы G_shock_2 часами?");
                    Console.WriteLine(clock2 is Clock);
                    Console.WriteLine(new string('_', 100));
                }

                if (info.KeyChar == '6')
                {
                    Console.Clear();
                    try
                    {
                        foreach (Product produc in products)
                        {
                            Console.WriteLine(produc.ToString());
                        }
                    }
                    catch
                    {
                        throw new ArgumentOutOfRangeException("Выход за пределы массива");
                    }
                    Console.WriteLine(new string('_', 100));
                }

                if (info.KeyChar == '7')
                {
                    Console.WriteLine("1)Добавить подарок\n2)Вывести содержимое подарка\n3)Удаление содержимого из подарка\n4)Стоимость подарка\n5)Самый лёгкий элемент подарка");
                    info = Console.ReadKey(true);
                    Console.Clear();
                    if (info.KeyChar == '1')
                    {
                        Console.Clear();
                        for (Int32 i = 0; i < products.Length; i++)
                        {
                            gift.List.Add(products[i]);
                        }
                        Console.WriteLine("Вещи добавлены");
                        Console.WriteLine(new string('_', 100));
                    }

                    if (info.KeyChar == '2')
                    {
                        for (Int32 i = 0; i < gift.List.Count; i++)
                        {
                            Console.WriteLine(gift.List[i]);
                        }
                        Console.WriteLine(new string('_', 100));
                    }

                    if (info.KeyChar == '3')
                    {
                        Console.WriteLine("1)Удалить ВСЁ\n2)Удалить выбранный элемент");
                        info = Console.ReadKey(true);
                        Console.Clear();
                        if (info.KeyChar == '1')
                        {
                            gift.List.Clear();
                        }
                        if (info.KeyChar == '2')
                        {
                            Int32 elem;
                            Console.WriteLine("Введите индекс элемента, который вы хотите удалить:");
                            while (!Int32.TryParse(Console.ReadLine(), out elem))
                            {
                                Console.Clear();
                                Console.WriteLine("Введите корректное число!");
                            }
                            gift.List.RemoveAt(elem);
                            Console.WriteLine(new string('_', 100));
                        }
                    }

                    if (info.KeyChar == '4')
                    {
                        gift.FinalCoast();
                    }

                    if (info.KeyChar == '5')
                    {
                        gift.MinWeight();
                    }
                }

                if (info.KeyChar == '8')
                {
                    Person p = new Person();
                    try
                    {
                        p = new Person {
                            Name = "Сватар", Age = 17
                        };
                    }
                    catch (AgeException ex)
                    {
                        Console.Clear();
                        Console.WriteLine("Ошибка: " + ex.Message);
                    }
                    finally
                    {
                        Console.WriteLine(new String('_', 100));
                    }
                    Console.WriteLine(p.Name);
                    int[] aa = null;
                    Debug.Assert(aa != null, "Values array cannot be null");
                }

                if (info.KeyChar == '9')
                {
                    string[] str = new string[5];
                    try
                    {
                        str[7] = "anythinddddg";
                        Console.WriteLine("It's OK");
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        Console.WriteLine("IndexOutOfRangeException");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception");
                    }
                }

                if (info.KeyChar == '0')
                {
                    Console.Clear();
                    varint++;
                }
            }
        }
Example #20
0
 public void GiftCompleted(Gift gift)
 {
     ServiceEventSource.Current.Message($"Gift completed by {gift.MadeBy} for {gift.PersonId} - {gift.WishListItem.Name}");
 }
Example #21
0
        // tạo thiết lập điểm với thẻ cào
        public int CreateConfigCard(int CreateUserID, int Price, int Point, string Description, int Type, int TelecomType)
        {
            try
            {
                var configCardCurrent = cnn.Gifts.Where(u => u.IsActive.Equals(SystemParam.ACTIVE) && u.TelecomType.Value.Equals(TelecomType) && u.Price.Equals(Price)).ToList();

                //var configCardCurrent = from g in cnn.Gifts
                //                        where g.IsActive.Equals(SystemParam.ACTIVE) && g.TelecomType.Value.Equals(TelecomType) && g.Price.Equals(Price)
                //                        select new ListGiftWebOutputModel
                //                        {
                //                            ID = g.ID
                //                        };

                if (configCardCurrent != null && configCardCurrent.Count() > 0)
                {
                    return(SystemParam.EXISTING);
                }

                string Name = "";
                switch (TelecomType)
                {
                case SystemParam.TYPE_VIETTEL:
                    Name = "Thẻ " + SystemParam.TYPE_VIETTEL_STRING + " " + Price;
                    break;

                case SystemParam.TYPE_MOBIPHONE:
                    Name = "Thẻ " + SystemParam.TYPE_MOBIPHONE_STRING + " " + Price;
                    break;

                case SystemParam.TYPE_VINAPHONE:
                    Name = "Thẻ " + SystemParam.TYPE_VINAPHONE_STRING + " " + Price;
                    break;

                case SystemParam.TYPE_VIETNAMMOBILE:
                    Name = "Thẻ " + SystemParam.TYPE_VIETNAMMOBILE_STRING + " " + Price;
                    break;

                default:
                    break;
                }

                Gift gift = new Gift();
                gift.CreateUserID = CreateUserID;
                gift.Name         = Name;
                gift.Price        = Price;
                gift.Point        = Point;
                gift.Description  = Description;
                gift.Type         = Type;
                gift.TelecomType  = TelecomType;
                gift.Status       = SystemParam.STATUS_GIFT_ACTIVE;
                gift.IsActive     = SystemParam.ACTIVE;
                gift.CreateDate   = DateTime.Now;
                cnn.Gifts.Add(gift);
                cnn.SaveChanges();
                return(SystemParam.SUCCESS);
            }
            catch (Exception e)
            {
                e.ToString();
                return(SystemParam.ERROR);
            }
        }
Example #22
0
 protected GiftTypeState(Gift gift)
 {
     this.Gift = gift;
 }
Example #23
0
 public void CostTotal()
 {
     DbInitializer.Initialize(Db);
     Assert.AreEqual(30, Gift.TotalCost(Db));
 }
        public static async Task <ServiceResponse> CreateVoucherAsync(Voucher voucher, Discount discount, Gift gift, Redemption redemption, Code_Config code_Config, MetaData metaData)
        {
            try
            {
                int rowAffected = 0;
                using (var conn = Connection)
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    //Parameters Declaration to be passed into Stored procdure "InsertVoucher"..
                    DynamicParameters parameters = new DynamicParameters();
                    parameters.Add("@Code", voucher.Code);
                    parameters.Add("@VoucherType", voucher.Voucher_type);
                    parameters.Add("@DiscountType", discount.Discount_type);
                    parameters.Add("@DiscountPercentOff", discount.Percent_Off);
                    parameters.Add("@DiscountAmountOff", discount.Amount_Off);
                    parameters.Add("@DiscountAmountLimit", discount.AmountLimit);
                    parameters.Add("@DiscountUnitOff", discount.Unit_Off);
                    parameters.Add("@DiscountUnitType", discount.Unit_Type);
                    parameters.Add("@GiftAmount", gift.Amount);
                    parameters.Add("@VoucherCategory", voucher.Category);
                    parameters.Add("@VoucherAdditionalInfo", voucher.Additional_Info);
                    parameters.Add("@VoucherStartDate", voucher.Start_Date);
                    parameters.Add("@VoucherExpirationDate", voucher.Expiration_Date);
                    parameters.Add("@VoucherActiveStatus", voucher.Active);
                    parameters.Add("@RedemptionQuantity", redemption.Quantity);
                    parameters.Add("@CodePrefix", code_Config.prefix);
                    parameters.Add("@CodeSuffix", code_Config.suffix);
                    parameters.Add("@CodeLength", code_Config.length);
                    parameters.Add("@CodeCharset", code_Config.charset);
                    parameters.Add("@VoucherMetaData", metaData.Meta_Data);

                    rowAffected = await conn.ExecuteAsync("InsertVoucher", parameters, commandType : CommandType.StoredProcedure);
                }

                //response using predefined serviceresponse class
                ServiceResponse response = new ServiceResponse("0", "Good Request", "Request Completed");
                return(response);
            }
            catch (Exception e)
            {
                //error response
                ServiceResponse response = new ServiceResponse("100", "Unsuccessful", "Request could not be completed");
                return(response);
            }
        }
Example #25
0
 public static double DistanceTo(this Gift one, Gift two)
 {
     return(one.Location.DistanceTo(two.Location));
 }
Example #26
0
        public async Task <ActionResult> Charge(ChargeModel model, CallLog calls)
        {
            var result = await MakeStripeCharge(model);

            if (result.Succeeded)
            {
                var currentPledge = model.PledgeAmount;

                // constituent id passed
                int constituentID = Convert.ToInt16(Session["constituentID"].ToString());

                // returns entire constituent
                Constituent constituent = db.Constituents.SingleOrDefault(x => x.ConstituentID == constituentID);

                // Get current constituent ID and set as a string
                int callId = Convert.ToInt16(Session["constituentID"].ToString());

                // Get current caller to send to new CallDetails
                var currentUser = UserManager.FindById(User.Identity.GetUserId());
                var userProfile = db.UserProfiles.Where(x => x.UserID == currentUser.Id).FirstOrDefault();
                var caller      = userProfile.UserID;

                if (constituent != null)
                {
                    // New call details with information
                    CallLog callInfo = new CallLog
                    {
                        ConstituentID = constituentID,
                        CallAnswered  = true,
                        LineAvailable = true,
                        DateOfCall    = DateTime.Now,
                        CallerID      = caller,
                        CallOutcome   = "Credit Card Donation",
                    };

                    // Create a new Gift entry
                    Gift giftInfo = new Gift
                    {
                        ConstituentID = constituentID,
                        CallID        = callInfo.CallID,
                        GiftAmount    = currentPledge,
                        GiftType      = "Credit Card Donation",
                        GiftRecipient = "General",
                    };

                    // Set constituent status to retained
                    constituent.DonationStatus = "Retained";

                    db.CallLogs.Add(callInfo);
                    db.Gifts.Add(giftInfo);

                    db.SaveChanges();

                    var callDetails = db.CallLogs.Where(x => x.ConstituentID == constituentID).ToList();
                    var gift        = db.Gifts.Where(x => x.ConstituentID == constituentID).ToList();

                    if (callDetails != null && callDetails.Count > 0)
                    {
                        CallLog callDetail = callDetails.FirstOrDefault(x => x.DateOfCall.ToShortDateString() == DateTime.Now.ToShortDateString());
                        if (callDetail == null)
                        {
                            gift[0].GiftAmount = model.PledgeAmount;
                            db.SaveChanges();
                        }
                    }
                }

                db.SaveChanges();
                ViewBag.Message = $"The pledge of {model.PledgeAmount:C} was processed successfully.  Thank you!\n An email receipt has been sent to the email associated with {model.Name:C}";
            }
            else
            {
                ViewBag.ErrorMessage = $"There was a problem processing your pledge";
            }
            return(View("Index"));
        }
 public decimal TotalCost()
 {
     return(Gift.TotalCost(_context));
 }
Example #28
0
 public static Gift Send(Gift Regalito)
 {
     return(Regalito);
 }
Example #29
0
 public static int InsertGift(Gift gift)
 {
     SqlGiftProvider sqlGiftProvider = new SqlGiftProvider();
     return sqlGiftProvider.InsertGift(gift);
 }
Example #30
0
 public static bool UpdateGift(Gift gift)
 {
     SqlGiftProvider sqlGiftProvider = new SqlGiftProvider();
     return sqlGiftProvider.UpdateGift(gift);
 }
        private void ExecuteHandler(ClientSession session)
        {
            ClientSession client =
                ServerManager.Instance.Sessions.FirstOrDefault(s =>
                                                               s.Character?.Miniland == session.Character.MapInstance);
            MinilandObject mlobj =
                client?.Character.MinilandObjects.Find(s => s.ItemInstance.ItemVNum == MinigameVNum);

            if (mlobj != null)
            {
                const bool full = false;
                byte       game = (byte)(mlobj.ItemInstance.Item.EquipmentSlot);
                switch (Type)
                {
                //play
                case 1:
                    if (mlobj.ItemInstance.DurabilityPoint <= 0)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                               Language.Instance.GetMessageFromKey("NOT_ENOUGH_DURABILITY_POINT"), 0));
                        return;
                    }

                    if (session.Character.MinilandPoint <= 0)
                    {
                        session.SendPacket(
                            $"qna #mg^1^7^3125^1^1 {Language.Instance.GetMessageFromKey("NOT_ENOUGH_MINILAND_POINT")}");
                    }

                    session.Character.MapInstance.Broadcast(
                        UserInterfaceHelper.GenerateGuri(2, 1, session.Character.CharacterId));
                    session.Character.CurrentMinigame = (short)(game == 0 ? 5102 :
                                                                game == 1 ? 5103 :
                                                                game == 2 ? 5105 :
                                                                game == 3 ? 5104 :
                                                                game == 4 ? 5113 : 5112);
                    session.Character.MinigameLog = new MinigameLogDTO
                    {
                        CharacterId = session.Character.CharacterId,
                        StartTime   = DateTime.UtcNow.Ticks,
                        Minigame    = game
                    };
                    session.SendPacket($"mlo_st {game}");
                    break;

                //stop
                case 2:
                    session.Character.CurrentMinigame = 0;
                    session.Character.MapInstance.Broadcast(
                        UserInterfaceHelper.GenerateGuri(6, 1, session.Character.CharacterId));
                    break;

                case 3:
                    session.Character.CurrentMinigame = 0;
                    session.Character.MapInstance.Broadcast(
                        UserInterfaceHelper.GenerateGuri(6, 1, session.Character.CharacterId));
                    if (Point.HasValue && session.Character.MinigameLog != null)
                    {
                        session.Character.MinigameLog.EndTime = DateTime.UtcNow.Ticks;
                        session.Character.MinigameLog.Score   = Point.Value;

                        int level = -1;
                        for (short i = 0; i < SharedMinilandMethods.GetMinilandMaxPoint(game).Length; i++)
                        {
                            if (Point.Value > SharedMinilandMethods.GetMinilandMaxPoint(game)[i])
                            {
                                level = i;
                            }
                            else
                            {
                                break;
                            }
                        }

                        session.SendPacket(level != -1
                                ? $"mlo_lv {level}"
                                : $"mg 3 {game} {MinigameVNum} 0 0");
                    }

                    break;

                // select gift
                case 4:
                    if (session.Character.MinilandPoint >= 100 &&
                        session.Character.MinigameLog != null &&
                        Point.HasValue && Point.Value > 0 &&
                        SharedMinilandMethods.GetMinilandMaxPoint(game)[Point.Value - 1] < session.Character.MinigameLog.Score)
                    {
                        MinigameLogDTO dto = session.Character.MinigameLog;
                        DAOFactory.MinigameLogDAO.InsertOrUpdate(ref dto);
                        session.Character.MinigameLog = null;
                        Gift obj = SharedMinilandMethods.GetMinilandGift(MinigameVNum, Point.Value);
                        if (obj != null)
                        {
                            session.SendPacket($"mlo_rw {obj.VNum} {obj.Amount}");
                            session.SendPacket(session.Character.GenerateMinilandPoint());
                            List <ItemInstance> inv =
                                session.Character.Inventory.AddNewToInventory(obj.VNum, obj.Amount);
                            session.Character.MinilandPoint -= 100;
                            if (inv.Count == 0)
                            {
                                session.Character.SendGift(session.Character.CharacterId, obj.VNum, obj.Amount,
                                                           0, 0, false);
                            }

                            if (client != session)
                            {
                                switch (Point.Value)
                                {
                                case 0:
                                    mlobj.Level1BoxAmount++;
                                    break;

                                case 1:
                                    mlobj.Level2BoxAmount++;
                                    break;

                                case 2:
                                    mlobj.Level3BoxAmount++;
                                    break;

                                case 3:
                                    mlobj.Level4BoxAmount++;
                                    break;

                                case 4:
                                    mlobj.Level5BoxAmount++;
                                    break;
                                }
                            }
                        }
                    }

                    break;

                case 5:
                    session.SendPacket(session.Character.GenerateMloMg(mlobj, MinigameVNum));
                    break;

                //refill
                case 6:
                    if (!Point.HasValue || Point.Value < 0)
                    {
                        return;
                    }

                    if (session.Character.Gold > Point)
                    {
                        session.Character.Gold -= Point.Value;
                        session.SendPacket(session.Character.GenerateGold());
                        mlobj.ItemInstance.DurabilityPoint += Point.Value / 100;
                        session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                               string.Format(Language.Instance.GetMessageFromKey("REFILL_MINIGAME"),
                                                             Point.Value / 100)));
                        session.SendPacket(session.Character.GenerateMloMg(mlobj, MinigameVNum));
                    }

                    break;

                //gift
                case 7:
                    session.SendPacket(
                        $"mlo_pmg {MinigameVNum} {session.Character.MinilandPoint} {(mlobj.ItemInstance.DurabilityPoint < 1000 ? 1 : 0)} {(full ? 1 : 0)} {(mlobj.Level1BoxAmount > 0 ? $"392 {mlobj.Level1BoxAmount}" : "0 0")} {(mlobj.Level2BoxAmount > 0 ? $"393 {mlobj.Level2BoxAmount}" : "0 0")} {(mlobj.Level3BoxAmount > 0 ? $"394 {mlobj.Level3BoxAmount}" : "0 0")} {(mlobj.Level4BoxAmount > 0 ? $"395 {mlobj.Level4BoxAmount}" : "0 0")} {(mlobj.Level5BoxAmount > 0 ? $"396 {mlobj.Level5BoxAmount}" : "0 0")} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
                    break;

                //get gift
                case 8:
                    if (!Point.HasValue)
                    {
                        return;
                    }
                    int amount = 0;
                    switch (Point.Value)
                    {
                    case 0:
                        amount = mlobj.Level1BoxAmount;
                        break;

                    case 1:
                        amount = mlobj.Level2BoxAmount;
                        break;

                    case 2:
                        amount = mlobj.Level3BoxAmount;
                        break;

                    case 3:
                        amount = mlobj.Level4BoxAmount;
                        break;

                    case 4:
                        amount = mlobj.Level5BoxAmount;
                        break;
                    }

                    List <Gift> gifts = new List <Gift>();
                    for (int i = 0; i < amount; i++)
                    {
                        Gift gift = SharedMinilandMethods.GetMinilandGift(MinigameVNum, Point.Value);
                        if (gift != null)
                        {
                            if (gifts.Any(o => o.VNum == gift.VNum))
                            {
                                gifts.First(o => o.Amount == gift.Amount).Amount += gift.Amount;
                            }
                            else
                            {
                                gifts.Add(gift);
                            }
                        }
                    }

                    string str = string.Empty;
                    for (int i = 0; i < 9; i++)
                    {
                        if (gifts.Count > i)
                        {
                            short itemVNum          = gifts[i].VNum;
                            byte  itemAmount        = gifts[i].Amount;
                            List <ItemInstance> inv =
                                session.Character.Inventory.AddNewToInventory(itemVNum, itemAmount);
                            if (inv.Count > 0)
                            {
                                session.SendPacket(session.Character.GenerateSay(
                                                       $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {ServerManager.GetItem(itemVNum).Name} x {itemAmount}",
                                                       12));
                            }
                            else
                            {
                                session.Character.SendGift(session.Character.CharacterId, itemVNum, itemAmount, 0,
                                                           0, false);
                            }

                            str += $" {itemVNum} {itemAmount}";
                        }
                        else
                        {
                            str += " 0 0";
                        }
                    }

                    session.SendPacket(
                        $"mlo_pmg {MinigameVNum} {session.Character.MinilandPoint} {(mlobj.ItemInstance.DurabilityPoint < 1000 ? 1 : 0)} {(full ? 1 : 0)} {(mlobj.Level1BoxAmount > 0 ? $"392 {mlobj.Level1BoxAmount}" : "0 0")} {(mlobj.Level2BoxAmount > 0 ? $"393 {mlobj.Level2BoxAmount}" : "0 0")} {(mlobj.Level3BoxAmount > 0 ? $"394 {mlobj.Level3BoxAmount}" : "0 0")} {(mlobj.Level4BoxAmount > 0 ? $"395 {mlobj.Level4BoxAmount}" : "0 0")} {(mlobj.Level5BoxAmount > 0 ? $"396 {mlobj.Level5BoxAmount}" : "0 0")}{str}");
                    break;

                //coupon
                case 9:
                    List <ItemInstance> items = session.Character.Inventory
                                                .Where(s => s.ItemVNum == 1269 || s.ItemVNum == 1271).OrderBy(s => s.Slot).ToList();
                    if (items.Count > 0)
                    {
                        short itemVNum = items[0].ItemVNum;
                        session.Character.Inventory.RemoveItemAmount(itemVNum);
                        int point = itemVNum == 1269 ? 300 : 500;
                        mlobj.ItemInstance.DurabilityPoint += point;
                        session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                               string.Format(Language.Instance.GetMessageFromKey("REFILL_MINIGAME"), point)));
                        session.SendPacket(session.Character.GenerateMloMg(mlobj, MinigameVNum));
                    }

                    break;
                }
            }
        }
 void OnGiftSendFinished(Gift gift) {
     Debug.Log("Successfully sent " + gift.Payload.AssociatedItemId);
 }
Example #33
0
 public void AddRobotGift(Gift gift)
 {
     this.robotGifts.Add(gift);
 }
 void OnGiftHandOutSuccess(Gift gift) {
     // ... Show a nice animation of receiving the gift ...
 }
Example #35
0
       private void searchTextBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
       {
           var giftData = retrieveGiftData(selectedCategory, searchTextBox.Text);
           if (e.Key == Key.Enter)
           {
               Gift emptyGift = new Gift();
               emptyGift.GiftName = "No " + searchTextBox.Text + " gifts found!";
               emptyGift.GiftImageUri = "../Images/VioletTulip.jpg";

               giftData = new[] {emptyGift};
           }
           giftListBox.ItemsSource = giftData;
       }
        protected override void Seed(CarkiFelek.Model.DatabaseContext context)
        {
            Gift gift = new Gift();

            gift.GiftName    = "250 MB Internet Paketi";
            gift.Possibility = 20;
            gift.CanGetPoint = true;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "1 GB Internet Paketi";
            gift.Possibility = 5;
            gift.CanGetPoint = false;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "Boyner 25 TL Hediye Çeki";
            gift.Possibility = 5;
            gift.CanGetPoint = false;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "Koton 10 TL Hediye Çeki ";
            gift.Possibility = 10;
            gift.CanGetPoint = true;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "Blu TV 1 Aylık Abonelik ";
            gift.Possibility = 5;
            gift.CanGetPoint = false;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "10 TL Steam Cüzdan Kodu";
            gift.Possibility = 10;
            gift.CanGetPoint = true;
            context.Gifts.Add(gift);
            context.SaveChanges();

            gift.GiftName    = "Karavana";
            gift.Possibility = 45;
            gift.CanGetPoint = true;
            context.Gifts.Add(gift);
            context.SaveChanges();


            Point point = new Point();

            point.PointScore  = 75;
            point.Possibility = 5;
            context.Points.Add(point);
            context.SaveChanges();

            point.PointScore  = 100;
            point.Possibility = 4;
            context.Points.Add(point);
            context.SaveChanges();

            point.PointScore  = 500;
            point.Possibility = 1;
            context.Points.Add(point);
            context.SaveChanges();

            point.PointScore  = 5;
            point.Possibility = 50;
            context.Points.Add(point);
            context.SaveChanges();

            point.PointScore  = 0;
            point.Possibility = 40;
            context.Points.Add(point);
            context.SaveChanges();
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }
Example #37
0
        public void Insert(long? SenderFbid,long? ReceiverFbid,string ReceiverEmail,string WittyMessage,DateTime? CreatedDate,int? Blueikon,bool? Fbpost,string ReceiverName)
        {
            Gift item = new Gift();

            item.SenderFbid = SenderFbid;

            item.ReceiverFbid = ReceiverFbid;

            item.ReceiverEmail = ReceiverEmail;

            item.WittyMessage = WittyMessage;

            item.CreatedDate = CreatedDate;

            item.Blueikon = Blueikon;

            item.Fbpost = Fbpost;

            item.ReceiverName = ReceiverName;

            item.Save(UserName);
        }
Example #38
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="Gift">Gift实体对象</param>
 /// <returns>bool值,判断是否操作成功</returns>
 public bool Add(Gift model)
 {
     return(dal.Add(model));
 }
Example #39
0
 // POST: api/Gifts
 // Fiddler request body {"GiftName":"ball", "GirlGift":"true", "BoyGift":"false"}
 public void Post([FromBody] Gift gift)
 {
     GiftsRepository.Add(gift.GiftName, gift.GirlGift, gift.BoyGift);
 }
Example #40
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="Gift">Gift实体对象</param>
 /// <returns>bool值,判断是否操作成功</returns>
 public bool Change(Gift model)
 {
     return(dal.Change(model));
 }
Example #41
0
 public Gift Add(Gift gift)
 {
     _context.Gifts.Add(gift);
     _context.SaveChanges();
     return(gift);
 }
Example #42
0
        public void Update(int GiftKey,long? SenderFbid,long? ReceiverFbid,string ReceiverEmail,string WittyMessage,DateTime? CreatedDate,int? Blueikon,bool? Fbpost,string ReceiverName)
        {
            Gift item = new Gift();
            item.MarkOld();
            item.IsLoaded = true;

            item.GiftKey = GiftKey;

            item.SenderFbid = SenderFbid;

            item.ReceiverFbid = ReceiverFbid;

            item.ReceiverEmail = ReceiverEmail;

            item.WittyMessage = WittyMessage;

            item.CreatedDate = CreatedDate;

            item.Blueikon = Blueikon;

            item.Fbpost = Fbpost;

            item.ReceiverName = ReceiverName;

            item.Save(UserName);
        }
Example #43
0
        public ActionResult Delete(int id, Gift gift)
        {
            var data = AutoMapperHelper.MapToSameViewModel <Gift, GiftViewModel>(_giftService.GetById(id));

            return(View(data.ToVM()));
        }
Example #44
0
 public PartialViewResult GetGiftPreview(Gift gift)
 {
     return(PartialView("RegistryItemPreview", new GiftRow {
         IsFirst = true, Item = gift
     }));
 }
Example #45
0
 public static void Update(Gift gift)
 {
 }
Example #46
0
    public int InsertGift(Gift gift)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("InsertGift", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@GiftID", SqlDbType.Int).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@GiftName", SqlDbType.NVarChar).Value = gift.GiftName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return (int)cmd.Parameters["@GiftID"].Value;
        }
    }
Example #47
0
        public T GetEntity <T>(int[] ids) where T : ModelEntity
        {
            DSClient client = new DSClient(Models.Const.ApplicationId);
            int      userId;
            string   token;

            if (GetToken(out userId, out token))
            {
                var t = typeof(T);
                if (t == typeof(Application))
                {
                    Application app = client.GetApplication(userId, token, ids[0]);
                    return(app as T);
                }
                else if (t == typeof(Role))
                {
                    Role role = client.GetRole(userId, token, ids[0]);
                    return(role as T);
                }
                else if (t == typeof(Image))
                {
                    Image image = client.GetImage(userId, token, ids[0]);
                    return(image as T);
                }
                else if (t == typeof(Command))
                {
                    Command cmd = client.GetCommand(userId, token, ids[0]);
                    return(cmd as T);
                }
                else if (t == typeof(RoleCommand))
                {
                    RoleCommand rc = client.GetRoleCommand(userId, token, ids[0]);
                    return(rc as T);
                }
                else if (t == typeof(RoleCommandView))
                {
                    RoleCommandView rc = client.GetRoleCommandView(userId, token, ids[0]);
                    return(rc as T);
                }
                else if (t == typeof(User))
                {
                    User user = client.GetUser(userId, token, ids[0]);
                    return(user as T);
                }
                else if (t == typeof(UserApplicationInfo))
                {
                    UserApplicationInfo info = client.GetUserInfo(userId, token, ids[0], ids[1]);
                    return(info as T);
                }
                else if (t == typeof(RoomGroup))
                {
                    RoomGroup roomGroup = client.GetRoomGroup(userId, token, ids[0]);
                    return(roomGroup as T);
                }
                else if (t == typeof(Room))
                {
                    Room room = client.GetRoom(userId, token, ids[0]);
                    return(room as T);
                }
                else if (t == typeof(RoomRole))
                {
                    RoomRole rRole = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]);
                    return(rRole as T);
                }
                else if (t == typeof(GiftGroup))
                {
                    GiftGroup giftGroup = client.GetGiftGroup(userId, token, ids[0]);
                    return(giftGroup as T);
                }
                else if (t == typeof(Gift))
                {
                    Gift gift = client.GetGift(userId, token, ids[0]);
                    return(gift as T);
                }
                else if (t == typeof(BlockType))
                {
                    BlockType b = client.GetBlockType(userId, token, ids[0]);
                    return(b as T);
                }
                else if (t == typeof(BlockList))
                {
                    BlockList b = client.GetBlockList(userId, token, ids[0]);
                    return(b as T);
                }
                else if (t == typeof(RoomRole))
                {
                    RoomRole rr = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]);
                    return(rr as T);
                }
                else if (t == typeof(RoomConfig))
                {
                    RoomConfig c = client.GetRoomConfig(userId, token, ids[0]);
                    return(c as T);
                }
            }
            return(null);
        }
Example #48
0
    public bool UpdateGift(Gift gift)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateGift", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@GiftID", SqlDbType.Int).Value = gift.GiftID;
            cmd.Parameters.Add("@GiftName", SqlDbType.NVarChar).Value = gift.GiftName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
Example #49
0
 public void AddPlayerGift(Gift gift)
 {
     this.playerGifts.Add(gift);
 }
Example #50
0
    public Gift GetGiftFromReader(IDataReader reader)
    {
        try
        {
            Gift gift = new Gift
                (

                     DataAccessObject.IsNULL<int>(reader["GiftID"]),
                     DataAccessObject.IsNULL<string>(reader["GiftName"])
                );
             return gift;
        }
        catch(Exception ex)
        {
            return null;
        }
    }
Example #51
0
        /// <summary>
        /// mg packet
        /// </summary>
        /// <param name="packet"></param>
        public void MinigamePlay(MinigamePacket packet)
        {
            ClientSession   client = ServerManager.Instance.Sessions.FirstOrDefault(s => s.Character?.Miniland == Session.Character.MapInstance);
            MapDesignObject mlobj  = Session.CurrentMapInstance?.MapDesignObjects.FirstOrDefault(s => s.ItemInstance.ItemVNum == packet.MinigameVNum);

            if (mlobj == null)
            {
                return;
            }
            const bool full = false;
            byte       game = (byte)(mlobj.ItemInstance.Item.EquipmentSlot == 0 ? 4 + mlobj.ItemInstance.ItemVNum % 10 : (int)mlobj.ItemInstance.Item.EquipmentSlot / 3);

            switch (packet.Type)
            {
            //play
            case 1:
                if (mlobj.ItemInstance.DurabilityPoint <= 0)
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_DURABILITY_POINT"), 0));
                    return;
                }
                if (Session.Character.MinilandPoint <= 0)
                {
                    Session.SendPacket($"qna #mg^1^7^3125^1^1 {Language.Instance.GetMessageFromKey("NOT_ENOUGH_MINILAND_POINT")}");
                }
                Session.Character.MapInstance.Broadcast(UserInterfaceHelper.Instance.GenerateGuri(2, 1, Session.Character.CharacterId));
                Session.Character.CurrentMinigame = (short)(game == 0 ? 5102 : game == 1 ? 5103 : game == 2 ? 5105 : game == 3 ? 5104 : game == 4 ? 5113 : 5112);
                Session.SendPacket($"mlo_st {game}");
                break;

            //stop
            case 2:
                Session.Character.CurrentMinigame = 0;
                Session.Character.MapInstance.Broadcast(UserInterfaceHelper.Instance.GenerateGuri(6, 1, Session.Character.CharacterId));
                break;

            case 3:
                Session.Character.CurrentMinigame = 0;
                Session.Character.MapInstance.Broadcast(UserInterfaceHelper.Instance.GenerateGuri(6, 1, Session.Character.CharacterId));
                int Level = -1;
                for (short i = 0; i < GetMinilandMaxPoint(game).Count(); i++)
                {
                    if (packet.Point > GetMinilandMaxPoint(game)[i])
                    {
                        Level = i;
                    }
                    else
                    {
                        break;
                    }
                }
                Session.SendPacket(Level != -1
                        ? $"mlo_lv {Level}"
                        : $"mg 3 {game} {packet.MinigameVNum} 0 0");
                break;

            // select gift
            case 4:
                if (Session.Character.MinilandPoint >= 100)
                {
                    Gift obj = GetMinilandGift(packet.MinigameVNum, (int)packet.Point);
                    if (obj != null)
                    {
                        Session.SendPacket($"mlo_rw {obj.VNum} {obj.Amount}");
                        Session.SendPacket(Session.Character.GenerateMinilandPoint());
                        List <ItemInstance> inv = Session.Character.Inventory.AddNewToInventory(obj.VNum, obj.Amount);
                        Session.Character.MinilandPoint -= 100;
                        if (!inv.Any())
                        {
                            Session.Character.SendGift(Session.Character.CharacterId, obj.VNum, obj.Amount, 0, 0, false);
                        }

                        if (client != Session)
                        {
                            switch (packet.Point)
                            {
                            case 0:
                                mlobj.Level1BoxAmount++;
                                break;

                            case 1:
                                mlobj.Level2BoxAmount++;
                                break;

                            case 2:
                                mlobj.Level3BoxAmount++;
                                break;

                            case 3:
                                mlobj.Level4BoxAmount++;
                                break;

                            case 4:
                                mlobj.Level5BoxAmount++;
                                break;
                            }
                        }
                    }
                }
                break;

            case 5:
                Session.SendPacket(Session.Character.GenerateMloMg(mlobj, packet));
                break;

            //refill
            case 6:
                if (packet.Point == null)
                {
                    return;
                }
                if (Session.Character.Gold > packet.Point)
                {
                    Session.Character.Gold -= (int)packet.Point;
                    Session.SendPacket(Session.Character.GenerateGold());
                    mlobj.ItemInstance.DurabilityPoint += (int)(packet.Point / 100);
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey(string.Format("REFILL_MINIGAME", (int)packet.Point / 100))));
                    Session.SendPacket(Session.Character.GenerateMloMg(mlobj, packet));
                }
                break;

            //gift
            case 7:
                Session.SendPacket(
                    $"mlo_pmg {packet.MinigameVNum} {Session.Character.MinilandPoint} {(mlobj.ItemInstance.DurabilityPoint < 1000 ? 1 : 0)} {(full ? 1 : 0)} {(mlobj.Level1BoxAmount > 0 ? $"392 {mlobj.Level1BoxAmount}" : "0 0")} {(mlobj.Level2BoxAmount > 0 ? $"393 {mlobj.Level2BoxAmount}" : "0 0")} {(mlobj.Level3BoxAmount > 0 ? $"394 {mlobj.Level3BoxAmount}" : "0 0")} {(mlobj.Level4BoxAmount > 0 ? $"395 {mlobj.Level4BoxAmount}" : "0 0")} {(mlobj.Level5BoxAmount > 0 ? $"396 {mlobj.Level5BoxAmount}" : "0 0")} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
                break;

            //get gift
            case 8:
                int amount = 0;
                switch (packet.Point)
                {
                case 0:
                    amount = mlobj.Level1BoxAmount;
                    break;

                case 1:
                    amount = mlobj.Level2BoxAmount;
                    break;

                case 2:
                    amount = mlobj.Level3BoxAmount;
                    break;

                case 3:
                    amount = mlobj.Level4BoxAmount;
                    break;

                case 4:
                    amount = mlobj.Level5BoxAmount;
                    break;
                }
                List <Gift> gifts = new List <Gift>();
                for (int i = 0; i < amount; i++)
                {
                    Gift gift = GetMinilandGift(packet.MinigameVNum, (int)packet.Point);
                    if (gift != null)
                    {
                        if (gifts.Any(o => o.VNum == gift.VNum))
                        {
                            gifts.First(o => o.Amount == gift.Amount).Amount += gift.Amount;
                        }
                        else
                        {
                            gifts.Add(gift);
                        }
                    }
                }
                string str = string.Empty;
                for (int i = 0; i < 9; i++)
                {
                    if (gifts.Count > i)
                    {
                        List <ItemInstance> inv = Session.Character.Inventory.AddNewToInventory(gifts.ElementAt(i).VNum, gifts.ElementAt(i).Amount);
                        if (inv.Any())
                        {
                            Session.SendPacket(Session.Character.GenerateSay(
                                                   $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {ServerManager.Instance.GetItem(gifts.ElementAt(i).VNum).Name} x {gifts.ElementAt(i).Amount}", 12));
                        }
                        else
                        {
                            Session.Character.SendGift(Session.Character.CharacterId, gifts.ElementAt(i).VNum, gifts.ElementAt(i).Amount, 0, 0, false);
                        }
                        str += $" {gifts.ElementAt(i).VNum} {gifts.ElementAt(i).Amount}";
                    }
                    else
                    {
                        str += " 0 0";
                    }
                }
                Session.SendPacket(
                    $"mlo_pmg {packet.MinigameVNum} {Session.Character.MinilandPoint} {(mlobj.ItemInstance.DurabilityPoint < 1000 ? 1 : 0)} {(full ? 1 : 0)} {(mlobj.Level1BoxAmount > 0 ? $"392 {mlobj.Level1BoxAmount}" : "0 0")} {(mlobj.Level2BoxAmount > 0 ? $"393 {mlobj.Level2BoxAmount}" : "0 0")} {(mlobj.Level3BoxAmount > 0 ? $"394 {mlobj.Level3BoxAmount}" : "0 0")} {(mlobj.Level4BoxAmount > 0 ? $"395 {mlobj.Level4BoxAmount}" : "0 0")} {(mlobj.Level5BoxAmount > 0 ? $"396 {mlobj.Level5BoxAmount}" : "0 0")}{str}");
                break;

            //coupon
            case 9:
                List <ItemInstance> items = Session.Character.Inventory.Select(s => s.Value).Where(s => s.ItemVNum == 1269 || s.ItemVNum == 1271).OrderBy(s => s.Slot).ToList();
                if (items.Count > 0)
                {
                    Session.Character.Inventory.RemoveItemAmount(items.ElementAt(0).ItemVNum);
                    int point = items.ElementAt(0).ItemVNum == 1269 ? 300 : 500;
                    mlobj.ItemInstance.DurabilityPoint += point;
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey(string.Format("REFILL_MINIGAME", point))));
                    Session.SendPacket(Session.Character.GenerateMloMg(mlobj, packet));
                }
                break;
            }
        }
Example #52
0
 public void CreateGift(Gift gift)
 {
     _appDbContext.Gifts.Add(gift);
     _appDbContext.SaveChanges();
 }
Example #53
0
    public static Gift getRandomGift(Level level)
    {
        Gift gift = new Gift();
        //        gift = getPhoenixGift(gameStage);
        int i = Random.Range(0, 100);

        if (i >= 0 && i <= level.rewardChanceGroups["RAVEN"])
        {
            //gift = getPetGift();
            gift = getMoneyGift(50);
        }
        else if (i > level.rewardChanceGroups["RAVEN"] &&
                 i <= level.rewardChanceGroups["CAT"])
        {
            //gift = getPet2Gift();
            gift = getMoneyGift(50);
        }
        else if (i > level.rewardChanceGroups["CAT"] &&
                 i <= level.rewardChanceGroups["DRAGON"])
        {
            //gift = getPet3Gift();
            gift = getMoneyGift(50);
        }
        else if (i > level.rewardChanceGroups["DRAGON"] &&
                 i <= level.rewardChanceGroups["PHOENIX"])
        {
            gift = getExtraLifeGift();
        }
        else if (i > level.rewardChanceGroups["PHOENIX"] &&
                 i <= level.rewardChanceGroups["BJ_DOUBLE"])
        {
            gift = getDoubleJuiceGift();
        }
        else if (i > level.rewardChanceGroups["BJ_DOUBLE"] &&
                 i <= level.rewardChanceGroups["MONEY_50"])
        {
            gift = getMoneyGift(50);
        }
        else if (i > level.rewardChanceGroups["MONEY_50"] &&
                 i <= level.rewardChanceGroups["MONEY_100"])
        {
            gift = getMoneyGift(100);
        }
        else if (i > level.rewardChanceGroups["MONEY_100"] &&
                 i <= level.rewardChanceGroups["MONEY_150"])
        {
            gift = getMoneyGift(150);
        }
        else if (i > level.rewardChanceGroups["MONEY_150"] &&
                 i <= level.rewardChanceGroups["MONEY_200"])
        {
            gift = getMoneyGift(200);
        }
        else if (i > level.rewardChanceGroups["MONEY_200"] &&
                 i <= level.rewardChanceGroups["MONEY_250"])
        {
            gift = getMoneyGift(250);
        }
        else if (i > level.rewardChanceGroups["MONEY_250"])
        {
            gift = getMoneyGift(300);
        }

        gift = getDoubleJuiceGift(); // Muahj

        return(gift);
    }
Example #54
0
       private void button1_Click_2(object sender, RoutedEventArgs e)
        {
            var giftData = retrieveGiftData(selectedCategory, searchTextBox.Text);

            if (giftData.Any() == false)
            {
                Gift emptyGift = new Gift();
                emptyGift.GiftName = "No " + searchTextBox.Text + " gifts found!";
                emptyGift.GiftImageUri = "../Images/VioletTulip.jpg";

                giftData = new[] { emptyGift };
            }

            giftListBox.ItemsSource = giftData;
        }
Example #55
0
        public ActionResult Pay(decimal fee, string desc, List <UserJoinItemViewModel> joinItems, long id = 0, int type = 0, int count = 1)
        {
            ResultInfo       ri        = new ResultInfo();
            int              result    = 0;
            string           seq       = string.Empty;
            string           returnUri = string.Empty;
            JoinItemTypeEnum jointype  = JoinItemTypeEnum.None;

            try
            {
                BeginTran();
                long buyItemID = 0;
                var  now       = DateTime.Now;
                #region 校验
                if (fee <= 0)
                {
                    ri.Msg = "金额不正常(如何支付为0的金额呢?),请刷新页面重试";
                    return(Result(ri));
                }

                if (type == 0)
                {
                    ri.Msg = "支付异常,请刷新页面重试";
                    return(Result(ri));
                }
                if (type == 1)
                {
                    if (id == 0)
                    {
                        seq       = "CZ";
                        returnUri = "http://www.baixiaotangtop.com/User";
                    }
                    else
                    {
                        ri.Msg = "支付异常,请刷新页面重试";
                        return(Result(ri));
                    }
                }
                else
                {
                    if (id == 0)
                    {
                        ri.Msg = "支付异常,请刷新页面重试";
                        return(Result(ri));
                    }
                    if (type == 2)
                    {
                        #region 礼物、课程、数据相关逻辑
                        //先根据ID获取费用信息
                        var feeInfo = GiftFeeBLL.Instance.GetModel(id);
                        if (feeInfo != null)
                        {
                            long giftId = GetRequest <long>("mid");
                            if (giftId != feeInfo.GiftID)
                            {
                                ri.Msg = "商品信息不正确!";
                                return(Result(ri));
                            }

                            if (feeInfo.FeeType != 30)
                            {
                                ri.Msg = "商品价格信息有误!";
                                return(Result(ri));
                            }
                            else if (feeInfo.Fee != fee)
                            {
                                ri.Msg = "商品价格被篡改,请刷新页面重新支付";
                                return(Result(ri));
                            }

                            if (feeInfo.FeeCount > 0)
                            {
                                if (feeInfo.FeeCount >= count)
                                {
                                    id        = giftId;
                                    returnUri = "http://www.baixiaotangtop.com/gift/detail/{0}".FormatWith(id);

                                    Gift gift = GiftBLL.Instance.GetModel(giftId);
                                    if (gift != null)
                                    {
                                        #region 创建购买商品信息
                                        string   linkMan = GetRequest("LinkMan");
                                        string   linktel = GetRequest("LinkTel");
                                        UserGift buygift = new UserGift()
                                        {
                                            BuyCount  = count,
                                            BuyTime   = now,
                                            BuyUserID = UserID,
                                            Fee       = feeInfo.Fee * count,
                                            FeeType   = feeInfo.FeeType,
                                            GiftFeeId = feeInfo.GiftFeeId,
                                            GiftID    = giftId,
                                            GType     = gift.GType,
                                            IsPay     = 0,
                                        };
                                        if (linkMan.IsNotNullOrEmpty())
                                        {
                                            buygift.LinkMan = linkMan;
                                        }
                                        if (linktel.IsNotNullOrEmpty())
                                        {
                                            buygift.LinkTel = linktel;
                                        }
                                        if ((buyItemID = UserGiftBLL.Instance.Add(buygift, Tran)) < 1)
                                        {
                                            RollBack();
                                            ri.Msg = "创建订单失败!";
                                            return(Result(ri));
                                        }
                                        if (gift.GType == 1)
                                        {
                                            seq      = "LP";
                                            jointype = JoinItemTypeEnum.Gift;
                                        }
                                        else if (gift.GType == 2)
                                        {
                                            seq      = "SJ";
                                            type     = 4;
                                            jointype = JoinItemTypeEnum.DataAnalysis;
                                        }
                                        else
                                        {
                                            seq      = "KC";
                                            type     = 8;
                                            jointype = JoinItemTypeEnum.KeCheng;
                                        }

                                        #endregion
                                    }
                                    else
                                    {
                                        ri.Msg = "商品不存在";
                                        return(Result(ri));
                                    }
                                }
                                else
                                {
                                    ri.Msg = "当前余票不足{0}份,请重新选择数量!".FormatWith(count);
                                    return(Result(ri));
                                }
                            }
                            else
                            {
                                ri.Msg = "该票种已无余票!请购买其它票种或联系主办方!";
                                return(Result(ri));
                            }
                        }
                        else
                        {
                            ri.Msg = "商品不存在";
                            return(Result(ri));
                        }
                        #endregion
                    }
                    else
                    {
                        #region 活动相关逻辑
                        seq      = "HD";
                        jointype = JoinItemTypeEnum.Party;
                        ActivityFee activityfee = ActivityFeeBLL.Instance.GetModel(id);
                        if (activityfee != null)
                        {
                            long activityId = GetRequest <long>("mid");
                            if (activityId != activityfee.ActivityId)
                            {
                                ri.Msg = "活动信息不正确!";
                                return(Result(ri));
                            }
                            if (activityfee.FeeType != 30)
                            {
                                ri.Msg = "活动价格信息有误!";
                                return(Result(ri));
                            }
                            else if (activityfee.Fee != fee)
                            {
                                ri.Msg = "活动价格被篡改,请刷新页面重新支付";
                                return(Result(ri));
                            }

                            if (activityfee.FeeCount > 0)
                            {
                                if (activityfee.FeeCount >= count)
                                {
                                    #region 判断活动是否能够报名
                                    Activity party = ActivityBLL.Instance.GetModel(activityId);
                                    if (party != null && party.IsDelete == 0)
                                    {
                                        if (!ActivityBLL.Instance.CanJoinParty(party).Ok)
                                        {
                                            return(Result(ri));
                                        }
                                    }
                                    else
                                    {
                                        ri.Msg = "活动不存在!";
                                        return(Result(ri));
                                    }
                                    #endregion
                                    id        = activityId;
                                    returnUri = "http://www.baixiaotangtop.com/party/detail/{0}".FormatWith(id);

                                    #region 创建报名活动信息

                                    string       linkMan = GetRequest("LinkMan");
                                    string       linktel = GetRequest("LinkTel");
                                    ActivityJoin ajoin   = new ActivityJoin();
                                    ajoin.ActivityId    = activityId;
                                    ajoin.FeeType       = activityfee.FeeType;
                                    ajoin.IsFeed        = 0;
                                    ajoin.RealPayFee    = activityfee.Fee * count;
                                    ajoin.JoinCount     = count;
                                    ajoin.JoinTime      = now;
                                    ajoin.JoinUserID    = UserID;
                                    ajoin.JoinUserName  = UserInfo.UserName;
                                    ajoin.ActivityFeeId = activityfee.ActivityFeeId;
                                    if (linkMan.IsNotNullOrEmpty())
                                    {
                                        ajoin.LinkMan = linkMan;
                                    }
                                    if (linktel.IsNotNullOrEmpty())
                                    {
                                        ajoin.LinkTel = linktel;
                                    }
                                    if ((buyItemID = ActivityJoinBLL.Instance.Add(ajoin, Tran)) < 1)
                                    {
                                        RollBack();
                                        ri.Msg = "创建订单失败!";
                                        return(Result(ri));
                                    }
                                }
                                else
                                {
                                    ri.Msg = "当前余票不足{0}份,请重新选择数量!".FormatWith(count);
                                    return(Result(ri));
                                }
                            }
                            else
                            {
                                ri.Msg = "该票种已无余票!请购买其它票种或联系主办方!";
                                return(Result(ri));
                            }
                            #endregion
                        }
                        else
                        {
                            ri.Msg = "活动不存在";
                            return(Result(ri));
                        }
                        #endregion
                    }
                }
                #endregion

                #region 记录报名填写项
                bool insertOk = true;
                //记录报名填写项
                if (joinItems != null && joinItems.Count > 0)
                {
                    foreach (var join in joinItems)
                    {
                        JoinItemAnswerExt model = new JoinItemAnswerExt()
                        {
                            BuyerID               = UserID,
                            CreateTime            = now,
                            ItemAnswer            = join.Value,
                            JoinItemQuestionExtId = join.Id,
                            JoinMainID            = id,
                            JoinType              = jointype.GetHashCode()
                        };
                        if (JoinItemAnswerExtBLL.Instance.Add(model, Tran) <= 0)
                        {
                            insertOk = false;
                            break;
                        }
                    }
                }
                if (!insertOk)
                {
                    RollBack();
                    ri.Msg = "创建订单失败!";
                    return(Result(ri));
                }
                #endregion

                #region 创建订单
                string payOrderID = string.Empty;
                string _msg_      = _orderService.CreateOrder(UserID, fee, id, type, desc, seq, count, now, Tran, out result, out payOrderID);
                if (result < 1)
                {
                    ri.Msg = _msg_;
                    RollBack();
                    return(Result(ri));
                }
                #endregion

                //记录用户购买单号
                SessionHelper.Set(payOrderID, buyItemID);

                #region 跳转支付
                ri = Redirect2Pay(desc, fee * count, payOrderID, returnUri, ConfigHelper.AppSettings("AliPayNotify"));
                if (ri.Ok)
                {
                    Commit();
                }
                else
                {
                    RollBack();
                }
                #endregion
            }
            catch
            {
                RollBack();
                ri.Msg = "支付异常,请重试!";
            }
            return(Result(ri));
        }
Example #56
0
        public Gift Get(int GiftNumber)
        {
            Gift gift = gifts.First(g => g.GiftNumber == GiftNumber);

            return(gift);
        }
Example #57
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="Gift">Gift实体对象</param>
 /// <returns>int值,返回自增ID</returns>
 public int AddReturnId(Gift model)
 {
     return(dal.AddReturnId(model));
 }
Example #58
0
        public AttachmentsItem(double width, Thickness margin, List <Attachment> attachments, Geo geo, string itemId, bool friendsOnly = false, bool isCommentAttachments = false, bool isMessage = false, bool isHorizontal = false, double horizontalWidth = 0.0, bool rightAlign = false, bool wallPostWithCommentsPage = false, string hyperlinkId = "")
            : base(width, margin, new Thickness())
        {
            this._hyperlinkId            = hyperlinkId;
            this._itemId                 = itemId;
            this._attachments            = attachments ?? new List <Attachment>();
            this._gifAttachments         = new List <Attachment>();
            this._photoAttachments       = new List <Attachment>();
            this._videoAttachments       = new List <Attachment>();
            this._albumAttachments       = new List <Attachment>();
            this._marketAlbumAttachments = new List <Attachment>();
            this._audioAttachments       = new List <Attachment>();
            this._docImageAttachments    = new List <Attachment>();
            if (this._attachments != null)
            {
                foreach (Attachment attachment in this._attachments)
                {
                    string type = attachment.type;

                    //uint stringHash = PrivateImplementationDetails.ComputeStringHash(type);

                    /*
                     * if (stringHash <= 2322801903U)
                     * {
                     * if (stringHash <= 1665450665U)
                     * {
                     * if ((int) stringHash != 232457833)
                     * {
                     *  if ((int) stringHash != 611394536)
                     *  {
                     *    if ((int) stringHash == 1665450665 && type == "market_album")
                     *    {
                     *      this._marketAlbumAttachments.Add(attachment);
                     *      continue;
                     *    }
                     *    continue;
                     *  }
                     *  if (!(type == "wall_ads"))
                     *    continue;
                     * }
                     * else
                     * {
                     *  if (type == "link")
                     *  {
                     *    Link link = attachment.link;
                     *    if ((link != null ? link.photo : (Photo) null) != null && link.photo.width > 0 && link.photo.height > 0)
                     *    {
                     *      this._link = link;
                     *      continue;
                     *    }
                     *    continue;
                     *  }
                     *  continue;
                     * }
                     * }
                     * else
                     * {
                     * if (stringHash <= 1876330552U)
                     * {
                     *  if ((int) stringHash != 1694181484)
                     *  {
                     *    if ((int) stringHash == 1876330552 && type == "poll")
                     *    {
                     *      this._poll = attachment.poll;
                     *      continue;
                     *    }
                     *    continue;
                     *  }
                     *  if (type == "album")
                     *  {
                     *    this._albumAttachments.Add(attachment);
                     *    continue;
                     *  }
                     *  continue;
                     * }
                     * if ((int) stringHash != -2128144669)
                     * {
                     *  if ((int) stringHash == -1972165393 && type == "gift")
                     *  {
                     *    this._giftAttachment = attachment.gift;
                     *    continue;
                     *  }
                     *  continue;
                     * }
                     * if (type == "photo")
                     * {
                     *  this._photoAttachments.Add(attachment);
                     *  continue;
                     * }
                     * continue;
                     * }
                     * }
                     * else if (stringHash <= 3343004700U)
                     * {
                     * if ((int) stringHash != -1490670315)
                     * {
                     * if ((int) stringHash != -1242026383)
                     * {
                     *  if ((int) stringHash == -951962596 && type == "sticker")
                     *  {
                     *    this._sticker = attachment.sticker;
                     *    continue;
                     *  }
                     *  continue;
                     * }
                     * if (type == "market")
                     * {
                     *  this._product = attachment.market;
                     *  continue;
                     * }
                     * continue;
                     * }
                     * if (!(type == "wall"))
                     * continue;
                     * }
                     * else
                     * {
                     * if (stringHash <= 3472427884U)
                     * {
                     * if ((int) stringHash != -896901342)
                     * {
                     *  if ((int) stringHash == -822539412 && type == "video")
                     *  {
                     *    this._videoAttachments.Add(attachment);
                     *    continue;
                     *  }
                     *  continue;
                     * }
                     * if (type == "wall_reply")
                     * {
                     *  this._commentAttachment = attachment.wall_reply;
                     *  continue;
                     * }
                     * continue;
                     * }
                     * if ((int) stringHash != -530499175)
                     * {
                     * if ((int) stringHash == -362233003 && type == "doc")
                     * {
                     *  if (!attachment.doc.IsVideoGif)
                     *  {
                     *    if (new DocumentHeader(attachment.doc, 0, false).HasThumbnail)
                     *    {
                     *      this._docImageAttachments.Add(attachment);
                     *      continue;
                     *    }
                     *    continue;
                     *  }
                     *  this._gifAttachments.Add(attachment);
                     *  continue;
                     * }
                     * continue;
                     * }
                     * if (type == "audio")
                     * {
                     * this._audioAttachments.Add(attachment);
                     * continue;
                     * }
                     * continue;
                     * }*/
                    if (type == "photo")
                    {
                        this._photoAttachments.Add(attachment);
                        continue;
                    }
                    else if (type == "link")
                    {
                        Link link = attachment.link;
                        if ((link != null ? link.photo : null) != null && link.photo.width > 0 && link.photo.height > 0)
                        {
                            this._link = link;
                            continue;
                        }
                        continue;
                    }
                    else if (type == "audio")
                    {
                        this._audioAttachments.Add(attachment);
                        continue;
                    }
                    else if (type == "doc")
                    {
                        if (attachment.doc.IsGraffiti)// UPDATE: 4.8.0
                        {
                            this._graffitiDoc = attachment.doc;
                            continue;
                        }
                        if (!attachment.doc.IsVideoGif)
                        {
                            if (new DocumentHeader(attachment.doc, 0, false).HasThumbnail)
                            {
                                this._docImageAttachments.Add(attachment);
                                continue;
                            }
                            continue;
                        }
                        this._gifAttachments.Add(attachment);
                        continue;
                    }
                    else if (type == "video")
                    {
                        this._videoAttachments.Add(attachment);
                        continue;
                    }
                    else if (type == "wall_reply")
                    {
                        this._commentAttachment = attachment.wall_reply;
                        continue;
                    }
                    else if (type == "album")
                    {
                        this._albumAttachments.Add(attachment);
                        continue;
                    }
                    else if (type == "poll")
                    {
                        this._poll = attachment.poll;
                        continue;
                    }
                    else if (type == "gift")
                    {
                        this._giftAttachment = attachment.gift;
                        continue;
                    }
                    else if (type == "sticker")
                    {
                        this._sticker = attachment.sticker;
                        continue;
                    }
                    else if (type == "market")
                    {
                        this._product = attachment.market;
                        continue;
                    }
                    else if (type == "market_album")
                    {
                        this._marketAlbumAttachments.Add(attachment);
                        continue;
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("AttachmentsItem.AttachmentsItem " + type);
                    }

                    this._wallAttachment = attachment.wall;
                }
            }
            this._geo                      = geo;
            this._friendsOnly              = friendsOnly;
            this._isCommentAttachments     = isCommentAttachments;
            this._isMessage                = isMessage;
            this._isHorizontal             = isHorizontal;
            this._horizontalWidth          = horizontalWidth;
            this._verticalWidth            = width;
            this._wallPostWithCommentsPage = wallPostWithCommentsPage;
            this._rightAlign               = rightAlign;
            if (this._isHorizontal)
            {
                this.Width = horizontalWidth;
            }
            this.CreateOrUpdateLayout();
        }
Example #59
0
        static void Main(string[] args)
        {
            SystemConsole.WriteLine("Hello World!");

            foreach (IFactory factory in Factories)
            {
                IFactoryObject factoryObject = factory.MakeObject();
                factoryObject.PrintSelf();
            }

            IBuiltObject builtObject1 =
                new Builder(_logger)
                .Start()
                .Annoying()
                .Loud()
                .WithColor(ConsoleColor.Green)
                .Build();

            IBuiltObject builtObject2 =
                new Builder(_logger)
                .Start()
                .Quiet()
                .WithColor(ConsoleColor.Yellow)
                .Build();

            builtObject1.PrintSelf();
            builtObject2.PrintSelf();

            foreach (IFactoryMethod factoryMethod in FactoryMethods)
            {
                IFactoryObject factoryObject = factoryMethod.CreateObject();
                factoryObject.PrintSelf();
            }

            IPrototype prototype = Prototype.InitialPrototype.Clone();

            for (int i = 0; i < 10; ++i)
            {
                SystemConsole.WriteLine($"prototype #{prototype.Id} copied");
                prototype = prototype.Clone();
            }

            Singleton singleton = Singleton.Instance;

            SystemConsole.WriteLine($"Singleton created at {singleton.CreationDateTime}");

            DivisionResult <int> divisionResult = _multiplyDivideAdapter.Divide(10, 3);

            SystemConsole.WriteLine($"{nameof(MultiplyDivideAdapter)}: 10 / 3 = {divisionResult.WholePart} with remainder {divisionResult.Remainder}");

            int multiplicationResult = _multiplyDivideAdapter.Multiply(10, 3);

            SystemConsole.WriteLine($"{nameof(MultiplyDivideAdapter)}: 10 x 3 = {multiplicationResult}");

            _logger.Log("Turn on hot");
            _hotWaterPipeBridge.TurnOn();
            _logger.Log("Turn off hot");
            _hotWaterPipeBridge.TurnOff();
            _logger.Log("Sprinkling hot");
            _hotWaterPipeBridge.Sprinkle();

            _logger.Log("Turn on cold");
            _coldWaterPipeBridge.TurnOn();
            _logger.Log("Turn off cold");
            _coldWaterPipeBridge.TurnOff();
            _logger.Log("Sprinkling cold");
            _coldWaterPipeBridge.Sprinkle();

            _TraverseCompositeTree(_composite);

            _logger.Log($"It seems we have a gift! First let's unwrap the {_wrapper.GetType().Name}");
            GiftBox giftBox = (_wrapper as WrappingPaper).Unwrap();

            _logger.Log($"We have the {giftBox.GetType().Name} open, now let's take our gift out.");
            Gift gift = giftBox.Open();

            _logger.Log($"The gift is a {gift.Name}!");

            _logger.Log($"Random divided numbers from facade: {_facade.GetRandomNumbersAndDivideThem()}");
            _logger.Log($"Random multiplied numbers from facade: {_facade.GetRandomNumbersAndMultiplyThem()}");

            SystemConsole.ReadLine();
        }
Example #60
0
        public ActionResult Edit(GiftCreateViewModel model)
        {
            ResultInfo ri = new ResultInfo();

            if (model.Gift.GiftID == model.GiftFees[0].GiftID)
            {
                Gift _model = GiftBLL.Instance.GetModel(model.Gift.GiftID);
                if (_model != null)
                {
                    if (_model.IsDelete == 0)
                    {
                        BeginTran();

                        _model.GiftName = model.Gift.GiftName;
                        _model.GiftDesc = model.Gift.GiftDesc;
                        _model.GiftImgs = model.Gift.GiftImgs;
                        _model.GiftInfo = HttpUtility.UrlDecode(model.Gift.GiftInfo);

                        _model.OpenJoinItem = model.Gift.OpenJoinItem;

                        if (GiftBLL.Instance.Update(_model, Tran).Ok)
                        {
                            var finalFees = model.GiftFees.Where(item => { return(item.Fee.HasValue && item.FeeCount.HasValue && item.FeeType.HasValue && item.FeeName.IsNotNullOrEmpty()); });
                            //更新费用
                            foreach (GiftFee fee in finalFees)
                            {
                                if (fee.GiftFeeId > 0)
                                {
                                    if (fee.GiftID == _model.GiftID)
                                    {
                                        //更新
                                        var feeModel = GiftFeeBLL.Instance.GetModel(fee.GiftFeeId);
                                        feeModel.FeeType  = fee.FeeType;
                                        feeModel.FeeName  = fee.FeeName;
                                        feeModel.Fee      = fee.Fee;
                                        feeModel.FeeCount = fee.FeeCount;
                                        feeModel.GiftID   = _model.GiftID;

                                        if (GiftFeeBLL.Instance.Update(feeModel, Tran).Ok)
                                        {
                                            ri.Ok = true;
                                        }
                                        else
                                        {
                                            ri.Ok = false;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        ri.Ok  = false;
                                        ri.Msg = "该费用列表异常!";
                                        break;
                                    }
                                }
                                else
                                {
                                    fee.GiftID = model.Gift.GiftID;
                                    if (GiftFeeBLL.Instance.Add(fee, Tran) > 0)
                                    {
                                        ri.Ok = true;
                                    }
                                    else
                                    {
                                        ri.Ok = false;
                                        break;
                                    }
                                }
                            }
                            if (ri.Ok)
                            {
                                //更新报名填写项
                                if (model.JoinItemQues != null)
                                {
                                    var finalJoins = model.JoinItemQues.Where(item => { return(item.ItemName.IsNotNullOrEmpty()); });
                                    foreach (var item in finalJoins)
                                    {
                                        if (item.JoinItemQuestionExtId > 0)
                                        {
                                            if (item.MainID == _model.GiftID)
                                            {
                                                //更新
                                                var joinItem = JoinItemQuestionExtBLL.Instance.GetModel(item.JoinItemQuestionExtId);
                                                joinItem.ItemName   = item.ItemName;
                                                joinItem.UpdateTime = DateTime.Now;
                                                joinItem.UpdateUser = UserID.ToString();
                                                if (JoinItemQuestionExtBLL.Instance.Update(joinItem, Tran).Ok)
                                                {
                                                    ri.Ok = true;
                                                }
                                                else
                                                {
                                                    ri.Ok = false;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                ri.Ok = false;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            item.MainID      = model.Gift.GiftID;
                                            item.MainType    = (_model.GType == 1 ? JoinItemTypeEnum.Gift : _model.GType == 2 ? JoinItemTypeEnum.DataAnalysis : JoinItemTypeEnum.KeCheng).GetHashCode();
                                            item.CreateTime  = DateTime.Now;
                                            item.CreateUser  = UserID.ToString();
                                            item.UpdateTime  = DateTime.Now;
                                            item.UpdateUser  = UserID.ToString();
                                            item.IsDelete    = 0;
                                            item.IsMustWrite = 1;
                                            if (JoinItemQuestionExtBLL.Instance.Add(item, Tran) > 0)
                                            {
                                                ri.Ok = true;
                                            }
                                            else
                                            {
                                                ri.Ok = false;
                                                break;
                                            }
                                        }
                                    }
                                }
                                if (ri.Ok)
                                {
                                    ri.Msg = "编辑成功";
                                    Commit();
                                }
                                else
                                {
                                    RollBack();
                                }
                            }
                            else
                            {
                                RollBack();
                            }
                        }
                    }
                    else
                    {
                        ri.Msg = "该商品已被删除,编辑失败";
                    }
                }
                else
                {
                    ri.Msg = "异常";
                }
            }
            else
            {
                ri.Msg = "异常";
            }
            return(Result(ri));
        }