public AppleDialogViewModel()
 {
     this.MyApple = new AppleModel()
     {
         Colour = "null", Name = "null"
     };
 }
Example #2
0
        public void ValidateBindInfoPasses()
        {
            var viewInstanceCreator = new DefaultViewInstanceCreator(
                (typeof(SpecifiedAttributeViewObj), new SpecifiedAttributeViewObj.ParamBinder()),
                (typeof(NoneAttributeViewObj), new NoneAttributeViewObj.ParamBinder()),
                (typeof(InvalidAttributeViewObj), new InvalidAttributeViewObj.ParamBinder())
                );

            ModelViewValidator.DoEnabled = true;

            {//Check BasicUsage
                var model    = new AppleModel();
                var bindInfo = new ModelViewBinder.BindInfo(typeof(SpecifiedAttributeViewObj));
                Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
            }

            {//Check None Attributes
                var model    = new AppleModel();
                var bindInfo = new ModelViewBinder.BindInfo(typeof(NoneAttributeViewObj));
                Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
            }

            {//Check Invalid Attributes
                var bindInfo = new ModelViewBinder.BindInfo(typeof(InvalidAttributeViewObj));
                var apple    = new AppleModel();
                Assert.IsFalse(ModelViewValidator.ValidateBindInfo(apple, bindInfo, viewInstanceCreator), "Invalid Model Case");

                bindInfo = new ModelViewBinder.BindInfo(
                    ModelViewBinder.BindInfo.ToID(typeof(InvalidAttributeViewObj)),
                    typeof(InvalidAttributeViewObj).FullName,
                    "invalidBinderKey");
                var orange = new OrangeModel();
                Assert.IsFalse(ModelViewValidator.ValidateBindInfo(orange, bindInfo, viewInstanceCreator), "Invalid Model Case");
            }
        }
Example #3
0
        public void AddApple(AppleModel apple)
        {
            Apple newApple = new Apple {
                TypeOfApple = apple.TypeOfApple, Price = apple.Price, Quantity = apple.Quantity
            };

            context.Apples.Add(newApple);
            context.SaveChanges();
        }
 public void SelectApple(AppleModel apple)
 {
     if (apple != null)
     {
         NavigationParameters p = new NavigationParameters();
         p.Add("apple", apple.Clone());
         this.SelectedApple = null;
         this._regionManager.RequestNavigate("RegionOne", nameof(Views.AppleDetail), p);
     }
 }
Example #5
0
        public ActionResult AdminAddApple(AppleModel apple)
        {
            if (ModelState.IsValid)
            {
                repo.AddApple(apple);

                return(RedirectToAction("AddAppleConfirmed", apple));
            }

            return(View(apple));
        }
        public void Draw()
        {
            Bitmap   flag         = new Bitmap(fieldSize, fieldSize);
            Graphics flagGraphics = Graphics.FromImage(flag);

            BallView.DrawBall(BallModel.GetBall(), flagGraphics);
            BlocksView.DrawBlocks(BlockModel.GetBlocks(), flagGraphics);
            TankView.DrawTanks(TankModel.GetTanks(), flagGraphics);
            AppleView.DrawApples(AppleModel.GetApples(), flagGraphics);

            pictureBox.Image = flag;
        }
Example #7
0
        public void ParamBinderSubclassValidateBindInfoPasses()
        {
            var viewInstanceCreator = new DefaultViewInstanceCreator(
                (typeof(SpecifiedAttributeViewObj), new SpecifiedAttributeViewObjParamBinderSubClass())
                );

            ModelViewValidator.DoEnabled = true;

            var model    = new AppleModel();
            var bindInfo = new ModelViewBinder.BindInfo(typeof(SpecifiedAttributeViewObj));

            Assert.IsTrue(ModelViewValidator.ValidateBindInfo(model, bindInfo, viewInstanceCreator));
        }
Example #8
0
        public int CheckCollision()
        {
            int score  = 0;
            var apples = AppleModel.GetApples();

            for (int i = 0; i < apples.Count(); i++)
            {
                if (appleModel.CheckCollision(apples.ToArray()[i]))
                {
                    score++;
                    i--;
                }
            }

            return(score);
        }
Example #9
0
        public ActionResult AppleEdit(AppleModel apple)
        {
            if (ModelState.IsValid)
            {
                Apple toBeUpdated = repo.GetAppleById(apple.Id);

                toBeUpdated.Price    = apple.Price;
                toBeUpdated.Quantity = apple.Quantity;

                repo.UpdateEditedApple(toBeUpdated);

                return(RedirectToAction("ManageProducts"));
            }

            return(View(apple));
        }
 public AppleModel SaveApple(AppleModel apple)
 {
     if (!apple.ID.HasValue)
     {
         int lastID = _appleList.Aggregate(0, (max, current) => { return(current.ID.Value > max ? current.ID.Value : max); });
         apple.ID = lastID + 1;
         this._appleList.Add(apple);
     }
     else
     {
         AppleModel theApple = this._appleList.Single(cur => cur.ID == apple.ID);
         theApple.Name   = apple.Name;
         theApple.Colour = apple.Colour;
     }
     return(apple);
 }
Example #11
0
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     if (navigationContext.Parameters.ContainsKey("apple"))
     {
         CurrentApple           = navigationContext.Parameters.GetValue <AppleModel>("apple");
         this.AppleReadOnlyMode = true;
         this.EditEnabled       = true;
         this.SaveEnabled       = false;
         PencilVisibility       = Visibility.Visible;
     }
     else
     {
         CurrentApple           = new AppleModel();
         this.AppleReadOnlyMode = false;
         this.EditEnabled       = false;
         this.SaveEnabled       = true;
         PencilVisibility       = Visibility.Hidden;
     }
 }
Example #12
0
        public ActionResult AddAppleToBasket(AppleModel apple)
        {
            var appleInStorage = repo.GetAppleById(apple.Id);

            if (appleInStorage.Quantity <= 0 || apple.Quantity > appleInStorage.Quantity)
            {
                ViewBag.Title = "Please insert correct quantity for the product!";
                return(View(appleInStorage));
            }
            else
            {
                repo.AppleDecreaseQuantity(apple.Quantity, appleInStorage.Id);
                repo.AddAppleToBasket(appleInStorage.Id, User.Identity.Name.ToString(), apple.Quantity);

                int storeId = Convert.ToInt32(TempData["storeId"]);
                return(RedirectToAction("AppleToBasketConfirmed", new
                {
                    appleId = apple.Id,
                    orderedQuantity = apple.Quantity,
                    storeId = storeId
                }));
            }
        }
 public AppleView(AppleModel model)
 {
     this._model = model;
Example #14
0
 public ActionResult AddAppleConfirmed(AppleModel apple)
 {
     return(View(apple));
 }