예제 #1
0
 public virtual void DetermineBreed(GoatBreed cb)
 {
     if (m_MotherBreed == m_FatherBreed)
     {
         this.Title = "[" + m_MotherBreed + "]";
     }
     else
     {
         this.Title = "[Mixed]";
     }
     if (cb == GoatBreed.Pyrenean)
     {
         Hue = 1816;
     }
     else if (cb == GoatBreed.Saanen)
     {
         Hue = 0;
     }
     else if (cb == GoatBreed.Angora)
     {
         Hue = 2311;
     }
     else if (cb == GoatBreed.Cashmere)
     {
         Hue = 1861;
     }
     else if (cb == GoatBreed.Boer)
     {
         Hue = 1810;
     }
     else if (cb == GoatBreed.Stiefelgeiss)
     {
         Hue = 1842;
     }
 }
예제 #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                m_KidFatherBreed = (GoatBreed)reader.ReadInt();
                m_MotherBreed    = (GoatBreed)reader.ReadInt();
                m_FatherBreed    = (GoatBreed)reader.ReadInt();
                m_Milk           = reader.ReadInt();
                m_LastMilking    = reader.ReadDateTime();
                m_CanMilk        = reader.ReadBool();
                m_NextWoolTime   = reader.ReadDeltaTime();
                goto case 0;
            }

            case 0:
            {
                break;
            }
            }
        }
        public IActionResult DeleteBreed(int id)
        {
            GoatBreed feed = _repo.GoatBreed.GetById(id);

            _repo.GoatBreed.Delete(id);

            return(RedirectToAction("Index"));
        }
        public IActionResult AddEditAnimal(int?id)
        {
            GoatBreed model = new GoatBreed();

            if (id.HasValue)
            {
                GoatBreed feed = _repo.GoatBreed.GetById(id.Value);

                if (feed != null)
                {
                    model = feed;
                }
            }
            return(View(model));
        }
예제 #5
0
 public override void OnAfterSpawn()
 {
     base.OnAfterSpawn();
     Name          = (this.Female ? "a nanny goat": "a billy goat");
     m_MotherBreed = (GoatBreed)Utility.Random(6);
     m_FatherBreed = (GoatBreed)Utility.Random(6);
     if (Utility.RandomBool())
     {
         DetermineBreed(m_MotherBreed);
     }
     else
     {
         DetermineBreed(m_FatherBreed);
     }
     TypeName = "a goat";
 }
 public ActionResult AddEditAnimal(int?id, GoatBreed model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool isNew = false;
             //FeedFooder feed = isNew ? new FeedFooder { } : _repo.GetById(id.Value);
             // feed = model;
             if (!id.HasValue)
             {
                 model.UpdatedBy = "admin";
                 isNew           = true;
             }
             if (isNew)
             {
                 model.Id        = 0;
                 model.UpdatedBy = "Admin";
                 model.UpdatedAt = DateTime.Now;
                 _repo.GoatBreed.Insert(model);
                 _repo.Save();
             }
             else
             {
                 //To Avoid tracking error
                 // DbContextInMemory.Entry(entity).State = EntityState.Detached;
                 _repo.GoatBreed.Update(model);
             }
         }
         else
         {
             return(View(model));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(RedirectToAction("Index"));
 }
        public IActionResult Details(int id)
        {
            GoatBreed feed = _repo.GoatBreed.GetById(id);

            return(View(feed));
        }