コード例 #1
0
        public Veggie GetVeggie(string id, double priceReduction)
        {
            Veggie veggie = _veggie.Find(veggie => veggie.Id == id).FirstOrDefault();

            veggie.Price = veggie.Price * priceReduction;
            return(veggie);
        }
コード例 #2
0
        public async Task <CreateVeggiePayload> UpdateVeggie([FromBody] UpdateVeggieParams payload)
        {
            try {
                // validate Id
                if (payload.Id == Guid.Empty)
                {
                    throw new Exception("Payload Id is empty.");
                }
                // find this veggie
                Veggie foundVeggie = await _veggieProcessor.GetById(payload.Id);

                if (foundVeggie == null)
                {
                    throw new Exception($"Unable to find Veggie by Id {payload.Id}");
                }

                // update the name and price
                foundVeggie.Name  = payload.Name;
                foundVeggie.Price = Convert.ToDouble(payload.Price);

                // update it
                bool inserted = await _veggieProcessor.Update(foundVeggie);

                if (inserted)
                {
                    return(new CreateVeggiePayload(true, ""));
                }
                return(new CreateVeggiePayload(false, "Update failed at the Data Access layer."));
            } catch (System.Exception) {
                return(new CreateVeggiePayload(false, "Server Error! Did you check your connection string?"));
            }
        }
コード例 #3
0
        //---------------------------------------------------------------------------------------------------------------
        private void WrongClick(Veggie veggie)
        {
            if (veggie == null)
            {
                return;
            }

            if (this.WrongWarnigDelay)
            {
                return;
            }
            this.Fails++;
            if (this.Fails >= MaxFails)
            {
                Game.Events.GameLost.Invoke();
                return;
            }
            if (Game.Settings.VibrationEnabled)
            {
                Handheld.Vibrate();
            }
            Game.AudioManager.PlaySound(AudioId.ClickNegative11);
            this.WrongWarnigDelay = true;
            Game.TimerManager.Start(0.3f, () => { this.WrongWarnigDelay = false; });
            PopedUIMsg.Pop(ObjectPoolName.WrongPop, veggie.transform.position);
        }
コード例 #4
0
        public async Task <IHttpActionResult> PutVeggie(int id, Veggie veggie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != veggie.Id)
            {
                return(BadRequest());
            }

            db.Entry(veggie).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VeggieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
 public Sandwich(Bread bread, Meat meat, Veggie veggie, Condiment condiment)
 {
     Bread     = bread;
     Meat      = meat;
     Veggie    = veggie;
     Condiment = condiment;
 }
コード例 #6
0
 public void OrderSandwich()
 {
     Meat.OrderMeat(Meat);
     Bread.OrderBread(Bread);
     Veggie.OrderVeggie(Veggie);
     Condiment.OrderCondiment(Condiment);
 }
コード例 #7
0
 public IActionResult AddVeggie(Veggie veggie)
 {
     if (ModelState.IsValid)
     {
         return(Json(veggie));
     }
     return(View("Veggie", veggie));
 }
コード例 #8
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Veggie veggie = await IngredientServices.GetAsync <Veggie>(id);

            await IngredientServices.DeleteAsync(veggie);

            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public void AddVeggie(string Name, int Qty)
        {
            Veggie newVeggie = new Veggie();

            newVeggie.Name = Name;
            newVeggie.Qty  = Qty;
            veggies.Add(newVeggie);
        }
コード例 #10
0
    /// <summary>
    /// Passes the veggie back to the interacting player, and removes it from itself at the same time.
    /// </summary>
    /// <returns></returns>
    public Veggie RemoveVeggie( )
    {
        Veggie veg = _model._currentVeggie;

        veg._veggieDetails._veggieType = _model._currentVeggie._veggieDetails._veggieType;
        _model._currentVeggie          = null;
        _view.RemoveVeggie( );
        return(veg);
    }
コード例 #11
0
    /// <summary>
    /// Places a Veggie on the plate.
    /// Assigns Veggie to its model and displays it through view.
    /// </summary>
    /// <param name="veg"></param>
    public void PlaceVeggie(Veggie veg)
    {
        if (_model._currentVeggie != null)
        {
            return;
        }

        _model._currentVeggie = veg;
        _view.PlaceVeggie(veg);
    }
コード例 #12
0
        public async Task <Veggie> GetById(string sql, Guid id)
        {
            using (SqlConnection conn = new SqlConnection(_connString)) {
                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.Add("Id", id, DbType.Guid, ParameterDirection.Input);
                Veggie thisVeggie = await conn.QueryFirstAsync <Veggie> (sql, dynamicParameters, commandType : CommandType.StoredProcedure);

                return(thisVeggie);
            }
        }
コード例 #13
0
 private void Drop()
 {
     exes.Add(veggie);
     score                = 0;
     carrying             = false;
     veggie.body.bodyType = RigidbodyType2D.Dynamic;
     anim.SetBool("carrying", false);
     veggie.body.velocity = pc.body.velocity * 1.1f;
     veggie = null;
 }
コード例 #14
0
        /// <summary>
        /// 初始化 <see cref="TokyoChickenBurger"/> 類別新的執行個體。
        /// </summary>
        /// <param name="bread">麵包。</param>
        /// <param name="veggie">蔬菜。</param>
        /// <param name="meat">肉類。</param>
        /// <param name="sauce">醬汁。</param>
        /// <exception cref="ArgumentNullException">sauce</exception>
        public TokyoPorkBurger(Bread bread, Veggie veggie, Meat meat, Sauce sauce)
            : base("Tokyo Pork Burger", bread, veggie, meat)
        {
            if (sauce == null)
            {
                throw new ArgumentNullException(nameof(sauce));
            }

            this._sauce = sauce;
        }
コード例 #15
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Price")] Veggie veggie)
        {
            if (ModelState.IsValid)
            {
                await IngredientServices.UpdateAsync(veggie);

                return(RedirectToAction("Index"));
            }
            return(View(veggie));
        }
コード例 #16
0
        public async Task <IHttpActionResult> GetVeggie(int id)
        {
            Veggie veggie = await db.Veggies.FindAsync(id);

            if (veggie == null)
            {
                return(NotFound());
            }

            return(Ok(veggie));
        }
コード例 #17
0
        public async Task <IHttpActionResult> PostVeggie(Veggie veggie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Veggies.Add(veggie);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = veggie.Id }, veggie));
        }
コード例 #18
0
    /// <summary>
    /// Locks ChoppingBoard.
    /// Sets the Veggie passed to it as ongoing.
    /// </summary>
    /// <param name="veg"></param>
    public void ChopNextVeggie(Veggie veg)
    {
        if (_model._isChoppingBoardBusy)
        {
            return;
        }

        _model._ongoingVeggie = new Veggie( );
        _model._ongoingVeggie = veg;
        _view.ChopNextVeggie(veg);
        _model._isChoppingBoardBusy = true;
    }
コード例 #19
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Area")
        {
            var area = collision.gameObject.GetComponentInParent <Area>();

            if (area.CanShow())
            {
                area.messages.ForEach(bubble.QueMessage);
                bubble.CheckQueuedMessages();
            }

            area.Toggle(true);
        }

        if (collision.gameObject.tag == "Veggie Activation")
        {
            if (Random.value < 0.1f + score * 0.01f)
            {
                var v = collision.gameObject.GetComponentInParent <Veggie>();
                v.Appear(score);
                v.bubble = vegBubble;
            }
        }

        if (collision.gameObject.tag == "Veggie Pull")
        {
            var veg = collision.gameObject.GetComponentInParent <Veggie>();

            if (veg.IsEx())
            {
                bubble.ShowMessage(veg.GetExInfo());

                if (!veggie)
                {
                    veggie = veg;
                }

                return;
            }

            if (!veggie)
            {
                bubble.ShowMessage("Looks like there is some (vegetable) here. I could pick it up with  <sprite=3>  or  <sprite=2>.");
                veggie = veg;
            }
            else if (veg != veggie)
            {
                bubble.ShowMessage("I can only carry one (veggie) at a time but I could still peek at it with\n  <sprite=3>  or  <sprite=2>.");
                peekVeggie = veg;
            }
        }
    }
コード例 #20
0
        // GET: Veggie/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }
            Veggie veggie = await IngredientServices.GetAsync <Veggie>(id);

            if (veggie == null)
            {
                return(View("Error"));
            }
            return(View(veggie));
        }
コード例 #21
0
        public async Task <IHttpActionResult> DeleteVeggie(int id)
        {
            Veggie veggie = await db.Veggies.FindAsync(id);

            if (veggie == null)
            {
                return(NotFound());
            }

            db.Veggies.Remove(veggie);
            await db.SaveChangesAsync();

            return(Ok(veggie));
        }
コード例 #22
0
ファイル: FullTest.cs プロジェクト: MrJJLand/project_pizzabox
        public void TestVeggie()
        {
            var tester     = new Veggie();
            var newCrust   = new Crust();
            var newSize    = new Size();
            var newTopping = new Topping();

            tester.AddCrust(newCrust);
            tester.AddSize(newSize);
            tester.AddToppings(newTopping);
            Assert.NotNull(tester.Crust);
            Assert.NotNull(tester.Size);
            Assert.NotNull(tester.Toppings);
        }
コード例 #23
0
        public async Task <SingleVeggiePayload> GetVeggieById(Guid id)
        {
            try {
                Veggie foundVeggie = await _veggieProcessor.GetById(id);

                if (foundVeggie != null)
                {
                    return(new SingleVeggiePayload(foundVeggie, true, ""));
                }
                else
                {
                    return(new SingleVeggiePayload(null, false, "Failed to find the Veggie in the database with the Id.  This is odd..."));
                }
            } catch (System.Exception) {
                return(new SingleVeggiePayload(null, false, "Server Error!  Did you check the connection string."));
            }
        }
コード例 #24
0
        public async Task <CreateVeggiePayload> CreateVeggie([FromBody] CreateVeggieParams payload)
        {
            try {
                // create method does server validation of from body arguments
                // if doesn't pass, an exception is thrown
                Veggie createdVeggie = _veggieProcessor.Create(payload.Name, Convert.ToDouble(payload.Price));

                // inserts into the db
                bool inserted = await _veggieProcessor.Insert(createdVeggie);

                if (inserted)
                {
                    return(new CreateVeggiePayload(true, ""));
                }
                return(new CreateVeggiePayload(false, "Insert Veggie failed at the Data Access layer."));
            } catch (System.Exception) {
                return(new CreateVeggiePayload(false, "Server Error!  Did you check your connection string?"));
            }
        }
コード例 #25
0
    /// <summary>
    /// Generates and outputs a random salad order for GenerateCustomer().
    /// </summary>
    /// <param name="salad">Outputs randomly generated salad combination.</param>
    /// <param name="time">Outputs a wait time for customer depending on the number of veggies in the salad combination.</param>
    private void GenerateRandomSaladOrder(out Veggie [] salad, out float time)
    {
        int randomVeggiesCount = UnityEngine.Random.Range(_minVeggiesCountInSalad, _maxVeggiesCountInSalad + 1);

        salad = new Veggie [randomVeggiesCount];

        for (int i = 0; i < salad.Length; i++)
        {
            salad [i] = _veggies [UnityEngine.Random.Range(0, _veggies.Length)];
        }

        if (randomVeggiesCount == _minVeggiesCountInSalad)
        {
            time = _timeForSmallOrder;
        }
        else
        {
            time = _timeForBiggerOrder;
        }
    }
コード例 #26
0
    private void SendInput(int dir)
    {
        var amount = inputs.Input(dir);

        if (amount >= 0)
        {
            pullAmount = amount;
        }
        else
        {
            veggie.Fail();
            veggie.DenyCauseFail();
            veggie           = null;
            pulling          = false;
            pc.body.bodyType = RigidbodyType2D.Dynamic;
            Invoke("ReturnControl", 0.3f);
        }

        hasReset = false;
    }
コード例 #27
0
        public async Task <bool> Update(string sql, Veggie veggie)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Enabled)) {
                using (SqlConnection conn = new SqlConnection(_connString)) {
                    DynamicParameters dynamicParameters = new DynamicParameters();
                    dynamicParameters.Add("Id", veggie.Id, DbType.Guid, ParameterDirection.Input);
                    dynamicParameters.Add("Name", veggie.Name, DbType.String, ParameterDirection.Input);
                    dynamicParameters.Add("Price", veggie.Price, DbType.Decimal, ParameterDirection.Input);

                    int rowsAffected = await conn.ExecuteAsync(sql, dynamicParameters, commandType : CommandType.StoredProcedure);

                    if (rowsAffected == 1)
                    {
                        // commit this transaction since only one row was updated
                        scope.Complete();
                        return(true);
                    }
                    throw new Exception("Something went wrong with the Update command.  The command did not return 1 row.");
                }
            }
        }
コード例 #28
0
ファイル: SliderFactory.cs プロジェクト: boogermanus/dotnet
        public Slider GetSlider(char key)
        {
            var slider = _sliders.ContainsKey(key) ? _sliders[key] : null;

            if (slider == null)
            {
                switch (key.ToString().ToUpper())
                {
                case BACON: slider = new BaconMaster(); break;

                case VEGGIE: slider = new Veggie(); break;

                case BBQ: slider = new BBQKing(); break;

                default: throw new Exception($"key: {key} not found");
                }
            }

            slider.OrderId = ++orderId;
            return(slider);
        }
コード例 #29
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Veggie Pull")
        {
            var veg = collision.gameObject.GetComponentInParent <Veggie>();

            if (veg == peekVeggie)
            {
                peekVeggie = null;
            }

            if (veg == veggie)
            {
                veggie = null;
            }
        }

        if (collision.gameObject.tag == "Area")
        {
            collision.gameObject.GetComponentInParent <Area>().Toggle(false);
        }
    }
コード例 #30
0
        public Burger(string name, Bread bread, Veggie veggie, Meat meat)
        {
            var paramsChecklist = new Dictionary <string, Func <bool> >
            {
                { nameof(name), () => string.IsNullOrWhiteSpace(name) },
                { nameof(bread), () => bread == null },
                { nameof(veggie), () => veggie == null },
                { nameof(meat), () => meat == null }
            };

            var paramName = paramsChecklist.FirstOrDefault(x => x.Value() == true).Key;

            if (string.IsNullOrWhiteSpace(paramName) == false)
            {
                throw new ArgumentException(paramName);
            }

            this._name   = name;
            this._bread  = bread;
            this._veggie = veggie;
            this._meat   = meat;
        }
コード例 #31
0
 public Veggie[] CreateVeggies()
 {
     Veggie[] veggies = new Veggie[] { new Garlic(), new Onion(), new Mushroom(), new RedPepper() };
     return veggies;
 }