public async Task <IActionResult> Edit(int id, [Bind("Id,EventId,UserId,OrderDate")] Orders orders)
        {
            if (id != orders.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdersExists(orders.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "UserName", orders.UserId);
            return(View(orders));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CategoryName")] Category category)
        {
            bool duplicate = await _context.Category.AnyAsync(c => c.CategoryName == category.CategoryName && c.Id != category.Id);

            if (duplicate)
            {
                ModelState.AddModelError("CategoryName", "This category already exists");
            }
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,PizzeriaId,ReviewDate,ReviewText")] Review review)
        {
            if (id != review.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(review);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReviewExists(review.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PizzeriaId"] = new SelectList(_context.Pizzeria, "Id", "Address", review.PizzeriaId);
            ViewData["UserId"]     = new SelectList(_context.Users, "Id", "UserName", review.UserId);
            return(View(review));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SpeciesName")] Species species)
        {
            bool duplicate = await _context.Species.AnyAsync(s => s.SpeciesName == species.SpeciesName && s.Id != species.Id);

            if (duplicate)
            {
                ModelState.AddModelError("SpeciesName", "This species already exists");
            }
            if (id != species.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(species);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpeciesExists(species.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(species));
        }
Ejemplo n.º 5
0
 public async Task <IActionResult> Edit(int id, int pizzeriaId, [Bind("Id,PizzeriaId,EventId")] PizzeriaEvent pizzeriaEvent)
 {
     if (id != pizzeriaEvent.Id)
     {
         return(NotFound());
     }
     ViewBag.PizzeriaId = pizzeriaId;
     ViewBag.EventId    = pizzeriaEvent.EventId;
     try
     {
         _context.Update(pizzeriaEvent);
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!PizzeriaEventExists(pizzeriaEvent.Id))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(RedirectToAction(nameof(Index)));
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserName")] Users users)
        {
            bool duplicate = await _context.Users.AnyAsync(u => u.UserName == users.UserName && u.Id != users.Id);

            if (duplicate)
            {
                ModelState.AddModelError("UserName", "This user already exists");
            }
            if (id != users.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(users);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,MealId,OrderId,MealCount")] MealOrder mealOrder)
        {
            if (id != mealOrder.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mealOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MealOrderExists(mealOrder.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MealId"]  = new SelectList(_context.Meal, "Id", "MealName", mealOrder.MealId);
            ViewData["OrderId"] = new SelectList(_context.Orders, "Id", "Id", mealOrder.OrderId);
            return(View(mealOrder));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PizzeriaName,Address,PizzeriaInfo")] Pizzeria pizzeria)
        {
            bool duplicate = await _context.Pizzeria.AnyAsync(p => p.PizzeriaName.ToLower() == pizzeria.PizzeriaName.ToLower() && p.Id != pizzeria.Id);

            if (duplicate)
            {
                ModelState.AddModelError("PizzeriaName", "This pizzeria already exists");
            }
            string temp = pizzeria.Address.ToString().ToLower();
            var    dub  = _context.Pizzeria.Where(p => p.Id != pizzeria.Id).Include(p => p.Animatronic).ToList();

            foreach (var obj in dub)
            {
                string temp1 = obj.Address.ToString().ToLower();
                if (temp1 == temp)
                {
                    ModelState.AddModelError("Address", "The pizzeria with this address already exists");
                    break;
                }
            }
            bool letCheck = pizzeria.PizzeriaName.Any(x => char.IsLetter(x));

            if (!letCheck)
            {
                ModelState.AddModelError("PizzeriaName", "Pizzeria name must have at least 1 letter in it!");
            }

            if (id != pizzeria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pizzeria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PizzeriaExists(pizzeria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pizzeria));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PizzeriaId,SpeciesId,AnimatronicName,AnimatronicInfo")] Animatronic animatronic)
        {
            bool duplicate = await _context.Animatronic.AnyAsync(a => a.AnimatronicName == animatronic.AnimatronicName && a.Id != animatronic.Id);

            if (duplicate)
            {
                ModelState.AddModelError("AnimatronicName", "This animatronic already exists");
            }
            bool letCheck = animatronic.AnimatronicName.Any(x => char.IsLetter(x));

            if (!letCheck)
            {
                ModelState.AddModelError("AnimatronicName", "Animatronic name must have at least 1 letter in it!");
            }

            if (id != animatronic.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animatronic);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimatronicExists(animatronic.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PizzeriaId"] = new SelectList(_context.Pizzeria, "Id", "PizzeriaName", animatronic.PizzeriaId);
            ViewData["SpeciesId"]  = new SelectList(_context.Species, "Id", "SpeciesName", animatronic.SpeciesId);
            return(View(animatronic));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,EventName,EventInfo,EventPrice")] Event Event)
        {
            bool duplicate = await _context.Event.AnyAsync(e => e.EventName == Event.EventName && e.Id != Event.Id);

            if (duplicate)
            {
                ModelState.AddModelError("EventName", "This Event already exists");
            }
            bool letCheck = Event.EventName.Any(x => char.IsLetter(x));

            if (!letCheck)
            {
                ModelState.AddModelError("EventName", "Event name must have at least 1 letter in it!");
            }

            if (id != Event.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(Event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(Event));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, int pizzeriaId, [Bind("Id,PizzeriaId,MealId")] PizzeriaMeal pizzeriaMeal)
        {
            if (id != pizzeriaMeal.Id)
            {
                return(NotFound());
            }
            ViewBag.PizzeriaId = pizzeriaId;
            ViewBag.MealId     = pizzeriaMeal.MealId;
            bool check = await _context.PizzeriaMeal.AnyAsync(p => p.MealId == pizzeriaMeal.MealId && p.PizzeriaId == pizzeriaId);

            if (check)
            {
                //ViewBag.ErrorMessage = "Error! This transfer already exists!";
                ModelState.AddModelError("MealId", "Error!");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pizzeriaMeal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PizzeriaMealExists(pizzeriaMeal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "PizzeriaMeals", new { id = pizzeriaId }));
            }
            ViewData["PizzeriaId"] = new SelectList(_context.Pizzeria, "Id", "PizzeriaName", pizzeriaMeal.PizzeriaId);
            ViewData["MealId"]     = new SelectList(_context.Meal, "Id", "MealName", pizzeriaMeal.MealId);
            return(View(pizzeriaMeal));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CategoryId,MealName,MealInfo,MealPrice")] Meal meal)
        {
            bool duplicate = await _context.Meal.AnyAsync(m => m.MealName == meal.MealName && m.Id != meal.Id);

            if (duplicate)
            {
                ModelState.AddModelError("MealName", "This meal already exists");
            }
            if (id != meal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(meal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MealExists(meal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "CategoryName", meal.CategoryId);
            return(View(meal));
        }