Beispiel #1
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,maxSeats,nearlyFullSeats,plentySeats")] SiteSettings siteSettings)
        {
            if (id != siteSettings.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //get the existing ID so we don't make a new row
                    var rowid = _context.SiteSettings.Select(a => a.Id).FirstOrDefault();
                    siteSettings.Id = rowid;

                    _context.Update(siteSettings);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SiteSettingsExists(siteSettings.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Create", "SeatBookings"));
            }
            return(View(siteSettings));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,isVisibleS1L,isVisibleS2L,isVisibleS3L,isVisibleS4L,isVisibleS5L,isVisibleS6L,isVisibleS7L,isVisibleS8L,isVisibleS9L,isVisibleS10L,isVisibleS11L,isVisibleS12L,isVisibleS13L,isVisibleS14L,isVisibleS15L,isVisibleS16L")] AdminData adminData)
        {
            if (id != adminData.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //get the existing ID so we don't make a new row
                    var rowid = _context.AdminData.Select(a => a.Id).FirstOrDefault();
                    adminData.Id = rowid;

                    _context.Update(adminData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdminDataExists(adminData.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction("Create", "SeatBookings"));
                //   return RedirectToAction(nameof(Index));
            }
            return(View(adminData));
        }
        public async Task <IActionResult> Edit(string id, [Bind("ID,Name,Email")] Students students)
        {
            if (id != students.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(students);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentsExists(students.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(students));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,SeatDate,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15, StudentEmail, Name")] SeatBooking seatBooking)
        {
            //get the date of last month
            DateTime LastMonth = DateTime.Today;

            LastMonth.AddMonths(-1);

            //if the date is older than lastmonth - catches when the date isn't being carried across
            if (id != seatBooking.ID && seatBooking.SeatDate < LastMonth && seatBooking.StudentEmail != string.Empty)
            {
                return(NotFound());
            }
            //only run if there is an email address
            if (ModelState.IsValid && !string.IsNullOrEmpty(seatBooking.StudentEmail))
            {
                try
                {
                    Students name = _context.Students.FirstOrDefault(s => s.Email == seatBooking.StudentEmail);

                    seatBooking.Name = name.Name;

                    _context.Update(seatBooking);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeatBookingExists(seatBooking.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(seatBooking));
        }