Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("TransactionId,ItemId,CustomerId,TotalCost,PurchaseDate,Quantity")] ItemPurchase itemPurchase)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(itemPurchase);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemPurchaseExists(itemPurchase.TransactionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (DbUpdateException) //catches trigger errors
                {
                    var _item = await _context.Items.FindAsync(itemPurchase.ItemId);

                    ViewData["Amount"] = _item.StockCount;
                    return(View("Error"));
                }
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerId", itemPurchase.CustomerId);
            ViewData["ItemId"]     = new SelectList(_context.Items, "ItemId", "Title", itemPurchase.ItemId);
            return(View(itemPurchase));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,PhoneNumber,Email,StreetName,ZipCode,City,State,Password")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(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> Create([Bind("DepartmentId,DepartmentName")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
        public async Task <IActionResult> Create([Bind("ShopId,DepartmentId,ShopName,Description,ImageUrl,Location")] GiftShop giftShop)
        {
            if (ModelState.IsValid)
            {
                _context.Add(giftShop);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", giftShop.DepartmentId);
            return(View(giftShop));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("EventId,DepartmentId,Date,Location,ImageUrl,Description")] Event @event)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@event);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", @event.DepartmentId);
            return(View(@event));
        }
        public async Task <IActionResult> Create([Bind("ExhibitId,DepartmentId,AnimalId,Name,ExhibitHabitat,Description,ImageUrl")] Exhibit exhibit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(exhibit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", exhibit.DepartmentId);
            return(View(exhibit));
        }
        public async Task <IActionResult> Create([Bind("TransactionId,CustomerId,TicketId,Price,ExpirationDate,PurchaseDate,IsValid")] TicketPurchase ticketPurchase)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ticketPurchase);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerId", ticketPurchase.CustomerId);
            return(View(ticketPurchase));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("StaffId,DepartmentId,FirstName,LastName,JobTitle,EmailAddress,HomeAddress,Salary,StartDate")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staff);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", staff.DepartmentId);
            return(View(staff));
        }
        public async Task <IActionResult> Create([Bind("ItemId,ShopId,Title,ImageUrl,Price,StockCount")] Items items)
        {
            if (ModelState.IsValid)
            {
                _context.Add(items);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ShopId"] = new SelectList(_context.GiftShop, "ShopId", "Description", items.ShopId);
            return(View(items));
        }
        public async Task <IActionResult> Create([Bind("EventId,DepartmentId,EventDate,Price,GuestCapacity,Location,EventType,ImageUrl,Description,IsBooked")] PrivateEvent privateEvent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(privateEvent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", privateEvent.DepartmentId);
            return(View(privateEvent));
        }
        public async Task <IActionResult> Create([Bind("AnimalId,ExhibitId,Name,Class,Birthdate,LastCheckup,Weight,Gender,ShortDescription")] Animal animal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExhibitId"] = new SelectList(_context.Exhibit, "ExhibitId", "Name", animal.ExhibitId);
            return(View(animal));
        }