示例#1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Allocate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllocateExists(Allocate.AllocateID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
示例#2
0
        public async Task OnGetAsync()
        {
            //     //Allocate = await _context.Allocate_1.ToListAsync();
            //     Allocate = await _context.Allocate_1
            //.Include(c => c.Volunteer)
            //.AsNoTracking()
            ////.ToListAsync();
            //Allocate = await _context.Allocate_1
            // .Include(c => c.Volunteer.Firstname)
            // .Include(c => c.Volunteer.Lastname)
            // .AsNoTracking()
            // .ToListAsync();
            await _context.SaveChangesAsync();

            AllocateVM = await _context.Volunteer
                         .Select(p => new AllocateViewModel
            {
                AllocateID = p.VolunteerID,
                Firstname  = p.Firstname,
                Lastname   = p.Lastname,
            })
                         .Include(p => p.IsAllocate)
                         .ToListAsync();



            async Task <IActionResult> OnPostAsync()
            {
                if (!ModelState.IsValid)
                {
                    return(Page());
                }

                _context.Attach(Allocate).State = EntityState.Modified;

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AllocateExists(Allocate.AllocateID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToPage("./Index"));
            }

            bool AllocateExists(int id)
            {
                return(_context.Allocate_1.Any(e => e.AllocateID == id));
            }
        }