public async Task <IActionResult> Edit(int id, [Bind("ItemId,ShopId,Title,ImageUrl,Price,StockCount")] Items items)
        {
            if (id != items.ItemId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Items _items = _context.Items.Where(s => s.ItemId == items.ItemId).First();
                    _items.Title      = items.Title;
                    _items.ImageUrl   = items.ImageUrl;
                    _items.Price      = items.Price;
                    _items.StockCount = items.StockCount;
                    _context.Update(_items);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemsExists(items.ItemId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ShopId"] = new SelectList(_context.GiftShop, "ShopId", "Description", items.ShopId);
            return(View(items));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DepartmentId,DepartmentName")] Department department)
        {
            if (id != department.DepartmentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Department _department = _context.Department.Where(s => s.DepartmentId == department.DepartmentId).First();
                    _department.DepartmentName = department.DepartmentName;
                    _context.Update(_department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.DepartmentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FirstName,LastName,PhoneNumber,Email,StreetName,ZipCode,City,State,Password")] Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Customer _customer = _context.Customer.Where(s => s.CustomerId == customer.CustomerId).First();
                    _customer.FirstName   = customer.FirstName;
                    _customer.LastName    = customer.LastName;
                    _customer.PhoneNumber = customer.PhoneNumber;
                    _customer.Email       = customer.Email;
                    _customer.StreetName  = customer.StreetName;
                    _customer.ZipCode     = customer.ZipCode;
                    _customer.City        = customer.City;
                    _customer.State       = customer.State;
                    _context.Update(_customer);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (DbUpdateException) //catches trigger errors
                {
                    return(View("Error"));
                }
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EventId,DepartmentId,EventDate,Price,GuestCapacity,Location,EventType,ImageUrl,Description,IsBooked")] PrivateEvent privateEvent)
        {
            if (id != privateEvent.EventId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    PrivateEvent _privateEvent = _context.PrivateEvent.Where(s => s.EventId == privateEvent.EventId).First();
                    _privateEvent.DepartmentId  = privateEvent.DepartmentId;
                    _privateEvent.EventDate     = privateEvent.EventDate;
                    _privateEvent.Price         = privateEvent.Price;
                    _privateEvent.GuestCapacity = privateEvent.GuestCapacity;
                    _privateEvent.Location      = privateEvent.Location;
                    _privateEvent.EventType     = privateEvent.EventType;
                    _privateEvent.ImageUrl      = privateEvent.ImageUrl;
                    _privateEvent.Description   = privateEvent.Description;
                    _privateEvent.IsBooked      = privateEvent.IsBooked;
                    _context.Update(_privateEvent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrivateEventExists(privateEvent.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", privateEvent.DepartmentId);
            return(View(privateEvent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("TransactionId,CustomerId,TicketId,Price,ExpirationDate,PurchaseDate,IsValid")] TicketPurchase ticketPurchase)
        {
            if (id != ticketPurchase.TicketId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    TicketPurchase _ticketPurchase = _context.TicketPurchase.Where(s => s.TransactionId == ticketPurchase.TransactionId).First();
                    _ticketPurchase.TransactionId  = ticketPurchase.TransactionId;
                    _ticketPurchase.CustomerId     = ticketPurchase.CustomerId;
                    _ticketPurchase.TicketId       = ticketPurchase.TicketId;
                    _ticketPurchase.Price          = ticketPurchase.Price;
                    _ticketPurchase.ExpirationDate = ticketPurchase.ExpirationDate;
                    _ticketPurchase.PurchaseDate   = ticketPurchase.PurchaseDate;
                    _ticketPurchase.IsValid        = ticketPurchase.IsValid;

                    _context.Update(_ticketPurchase);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TicketPurchaseExists(ticketPurchase.TicketId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerId", ticketPurchase.CustomerId);
            return(View(ticketPurchase));
        }
        public async Task <IActionResult> Edit(int id, [Bind("AnimalId,ExhibitId,Name,Class,Birthdate,LastCheckup,Weight,Gender,ShortDescription")] Animal animal)
        {
            if (id != animal.AnimalId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Animal _animal = _context.Animal.Where(s => s.AnimalId == animal.AnimalId).First();
                    _animal.ExhibitId        = animal.ExhibitId;
                    _animal.Name             = animal.Name;
                    _animal.Class            = animal.Class;
                    _animal.Birthdate        = animal.Birthdate;
                    _animal.LastCheckup      = animal.LastCheckup;
                    _animal.Weight           = animal.Weight;
                    _animal.Gender           = animal.Gender;
                    _animal.ShortDescription = animal.ShortDescription;
                    _context.Update(_animal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimalExists(animal.AnimalId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExhibitId"] = new SelectList(_context.Exhibit, "ExhibitId", "Name", animal.ExhibitId);
            return(View(animal));
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("TransactionId,ItemId,CustomerId,TotalCost,PurchaseDate,Quantity")] ItemPurchase itemPurchase)
        {
            if (id != itemPurchase.TransactionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ItemPurchase _itemPurchase = _context.ItemPurchase.Where(s => s.TransactionId == itemPurchase.TransactionId).First();
                    _itemPurchase.ItemId       = itemPurchase.ItemId;
                    _itemPurchase.CustomerId   = itemPurchase.CustomerId;
                    _itemPurchase.TotalCost    = itemPurchase.TotalCost;
                    _itemPurchase.PurchaseDate = itemPurchase.PurchaseDate;
                    _itemPurchase.Quantity     = itemPurchase.Quantity;
                    _context.Update(_itemPurchase);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemPurchaseExists(itemPurchase.TransactionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerId", itemPurchase.CustomerId);
            ViewData["ItemId"]     = new SelectList(_context.Items, "ItemId", "Title", itemPurchase.ItemId);
            return(View(itemPurchase));
        }
Example #8
0
        public async Task <IActionResult> Edit(int id, [Bind("StaffId,DepartmentId,FirstName,LastName,JobTitle,EmailAddress,HomeAddress,Salary,StartDate")] Staff staff)
        {
            if (id != staff.StaffId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Staff _staff = _context.Staff.Where(s => s.StaffId == staff.StaffId).First();
                    _staff.DepartmentId = staff.DepartmentId;
                    _staff.FirstName    = staff.FirstName;
                    _staff.LastName     = staff.LastName;
                    _staff.JobTitle     = staff.JobTitle;
                    _staff.EmailAddress = staff.EmailAddress;
                    _staff.HomeAddress  = staff.HomeAddress;
                    _staff.Salary       = staff.Salary;
                    _context.Update(_staff);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.StaffId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", staff.DepartmentId);
            return(View(staff));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ExhibitId,DepartmentId,AnimalId,Name,ExhibitHabitat,Description,ImageUrl")] Exhibit exhibit)
        {
            if (id != exhibit.ExhibitId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Exhibit _exhibit = _context.Exhibit.Where(s => s.ExhibitId == exhibit.ExhibitId).First();
                    _exhibit.DepartmentId   = exhibit.DepartmentId;
                    _exhibit.AnimalId       = exhibit.AnimalId;
                    _exhibit.Name           = exhibit.Name;
                    _exhibit.ExhibitHabitat = exhibit.ExhibitHabitat;
                    _exhibit.Description    = exhibit.Description;
                    _exhibit.ImageUrl       = exhibit.ImageUrl;
                    _context.Update(_exhibit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExhibitExists(exhibit.ExhibitId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", exhibit.DepartmentId);
            return(View(exhibit));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ShopId,DepartmentId,ShopName,Description,ImageUrl,Location")] GiftShop giftShop)
        {
            if (id != giftShop.ShopId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    GiftShop _giftShop = _context.GiftShop.Where(s => s.ShopId == giftShop.ShopId).First();
                    _giftShop.DepartmentId = giftShop.DepartmentId;
                    _giftShop.ShopName     = giftShop.ShopName;
                    _giftShop.Description  = giftShop.Description;
                    _giftShop.ImageUrl     = giftShop.ImageUrl;
                    _giftShop.Location     = giftShop.Location;
                    _context.Update(_giftShop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GiftShopExists(giftShop.ShopId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", giftShop.DepartmentId);
            return(View(giftShop));
        }
Example #11
0
        public async Task <IActionResult> Edit(int id, [Bind("EventId,DepartmentId,Date,Location,ImageUrl,Description")] Event @event)
        {
            if (id != @event.EventId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Event _event = _context.Event.Where(s => s.EventId == @event.EventId).First();
                    _event.DepartmentId = @event.DepartmentId;
                    _event.Date         = @event.Date;
                    _event.Location     = @event.Location;
                    _event.ImageUrl     = @event.ImageUrl;
                    _event.Description  = @event.Description;
                    _context.Update(_event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", @event.DepartmentId);
            return(View(@event));
        }