예제 #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var staff = await _context.Staff.FindAsync(id);

            if (staff == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Staff.Remove(staff);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException)
            {
                return(RedirectToAction("./Delete", new { id, saveError = true }));
            }
        }
예제 #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyActor = new Actor();

            if (await TryUpdateModelAsync <Actor>(emptyActor, "actor", a => a.ContractPrice, a => a.FirstName, a => a.LastName, a => a.PhoneNumber, a => a.Address)) // Overposting protection, only update the listed fields.
            {
                _context.Actors.Add(emptyActor);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            return(Page());
        }
예제 #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyStaff = new Staff();

            if (await TryUpdateModelAsync <Staff>(emptyStaff, "staff", s => s.Salary, s => s.PerformanceScore, s => s.FirstName, s => s.LastName, s => s.PhoneNumber, s => s.Address)) // Overposting protection, only update the listed fields.
            {
                _context.Staff.Add(emptyStaff);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            return(Page());
        }
예제 #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyContract = new Contract();

            if (await TryUpdateModelAsync <Contract>(emptyContract, "contract", c => c.StartDate, c => c.EndDate, c => c.TotalPrice, c => c.ActorID, c => c.ManagingStaffID)) // Overposting protection, only update the listed fields.
            {
                _context.Contracts.Add(emptyContract);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateDropDownList(_context, emptyContract.ManagingStaffID, emptyContract.ActorID);
            return(Page());
        }
예제 #5
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var staffToUpdate = await _context.Staff.FindAsync(id);

            if (staffToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Staff>(staffToUpdate, "staff", s => s.Salary, s => s.PerformanceScore, s => s.FirstName, s => s.LastName, s => s.PhoneNumber, s => s.Address)) // Overposting protection
            {
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            return(Page());
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var actorToUpdate = await _context.Actors.FindAsync(id);

            if (actorToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Actor>(actorToUpdate, "actor", a => a.ContractPrice, a => a.FirstName, a => a.LastName, a => a.PhoneNumber, a => a.Address)) // Overposting protection
            {
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            return(Page());
        }
예제 #7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var contractToUpdate = await _context.Contracts.FindAsync(id);

            if (contractToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Contract>(contractToUpdate, "contract", c => c.StartDate, c => c.EndDate, c => c.TotalPrice, c => c.ActorID, c => c.ManagingStaffID)) // Overposting protection, only update the listed fields.
            {
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateDropDownList(_context, contractToUpdate.ManagingStaffID, contractToUpdate.ActorID);
            return(Page());
        }