Esempio n. 1
0
 public ActionResult AddEat(Eats objbook)
 {
     if (ModelState.IsValid)
     {
         this.db.Eats.Add(objbook);
         this.db.SaveChanges();
         if (ViewBag.Id > 0)
         {
             ViewBag.Success = "Добавлено";
         }
         ModelState.Clear();
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 2
0
        public ActionResult EditEat(Eats objbook)
        {
            int StudentId   = (int)TempData["StudentId"];
            var StudentData = this.db.Eats.Where(b => b.Id == StudentId).FirstOrDefault();

            if (StudentData != null)
            {
                StudentData.Nimetus         = objbook.Nimetus;
                StudentData.Hind            = objbook.Hind;
                db.Entry(StudentData).State = EntityState.Modified;
                this.db.SaveChanges();
            }
            return(RedirectToAction("Admin"));
        }
        public NewAnimalViewModel()
        {
            AnimalData animalData = AnimalData.GetInstance();

            foreach (Size field in animalData.Sizes.ToList())
            {
                Sizes.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            foreach (Origin field in animalData.Origins.ToList())
            {
                Origins.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            foreach (Kind field in animalData.Kinds.ToList())
            {
                Kinds.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            foreach (Eat field in animalData.Eats.ToList())
            {
                Eats.Add(new SelectListItem
                {
                    Value = field.ID.ToString(),
                    Text  = field.Value
                });
            }

            // TODO #4 - populate the other List<SelectListItem>
            // collections needed in the view
        }
Esempio n. 4
0
 /// <summary>
 /// Increments the score everytime Pacman hits a dot, Energizer or scares ghosts
 /// </summary>
 /// <param name="collidable">The ICollidable that got hit</param>
 public void IncrementScore(ICollidable collidable)
 {
     if (collidable != null)
     {
         if ((collidable is Ghost))
         {
             //If Ghost is scared sends him to the pen.
             if (((Ghost)collidable).CurrentState == GhostState.Scared)
             {
                 this.Score += collidable.Points;
                 ((Ghost)collidable).ChangeState(GhostState.Zombie);
                 Eats?.Invoke(collidable);
             }
         }
         else
         {
             this.Score += collidable.Points;
             Eats?.Invoke(collidable);
         }
     }
 }
Esempio n. 5
0
 internal void Eat(IStone stone)
 {
     stone.Player.Stones.Remove(stone);
     Eats.Add(stone);
 }