コード例 #1
0
        public async Task <IActionResult> PutVolunteerOpps(int id, VolunteerOpps volunteerOpps)
        {
            if (id != volunteerOpps.Id)
            {
                return(BadRequest());
            }

            _context.Entry(volunteerOpps).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VolunteerOppsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <VolunteerOpps> > PostVolunteerOpps(VolunteerOpps volunteerOpps)
        {
            var currentUser = _context.Users.FirstOrDefault(f => f.EMail == User.Identity.Name);

            volunteerOpps.UserId = currentUser.Id;
            _context.VolunteerOpp.Add(volunteerOpps);
            await _context.SaveChangesAsync();

            return(Ok(volunteerOpps));
        }