Пример #1
0
        public async Task <IActionResult> Create([Bind("Name,Adress")] Shop shop)
        {
            shop.ID = Guid.NewGuid().GetHashCode();
            if (ModelState.IsValid)
            {
                _context.Add(shop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shop));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Number,Square")] Cage cage)
        {
            cage.ID     = Guid.NewGuid().GetHashCode();
            cage.ShopID = shopId;
            if (ModelState.IsValid)
            {
                _context.Add(cage);
                await _context.SaveChangesAsync();

                return(Redirect("https://localhost:44324/Cages/Details/" + shopId));
            }
            return(View(cage));
        }
Пример #3
0
 public IActionResult Choosecage([Bind("Name,Sex,ShopID,CageID,SpeciesID,Date,ColorID,Price")] Animal animal)
 {
     if (animal.CageID == null && animal.Name != null)
     {
         animal1 = animal;
         CagesDropDownList(animal.ShopID);
         return(View(animal));
     }
     animal1.CageID = animal.CageID;
     if (animal1.CageID == null)
     {
         Animal animal2 = animal1;
         return(Choosecage(animal2));
     }
     _context.Add(animal1);
     _context.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Name,LifeTime,Temperature")] Species species, string[] selectedFood)
        {
            species.ID = Guid.NewGuid().GetHashCode();
            if (selectedFood != null)
            {
                species.SpeciesFood = new List <SpeciesFood>();
                foreach (var food in selectedFood)
                {
                    var foodToAdd = new SpeciesFood {
                        SpeciesID = species.ID, FoodID = int.Parse(food), ID = Guid.NewGuid().GetHashCode()
                    };
                    species.SpeciesFood.Add(foodToAdd);
                }
            }
            if (ModelState.IsValid)
            {
                _context.Add(species);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(species));
        }
Пример #5
0
 public void AddNewAnimal(Animal newAnimal)
 {
     _context.Add(newAnimal);
     _context.SaveChanges();
 }
Пример #6
0
 public void Insert(Rabbit entity)
 {
     _db.Add(entity);
 }