示例#1
0
        public async Task <ActionResult <ApplicationUser> > PutUser(string id, ApplicationUser user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

            var previousUser = await _context.Users.FindAsync(id);

            UpdateProperties(previousUser, user);

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

            try
            {
                await _context.SaveChangesAsync();

                return(await _context.Users.FindAsync(id));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw ex;
                }
            }
        }
示例#2
0
        public async Task <ActionResult <Friendship> > PutFriendship(int id, Friendship friendship)
        {
            if (id != friendship.Id)
            {
                return(BadRequest());
            }

            var previousFriendship = await _context.Friendships.FindAsync(id);

            UpdateProperties(previousFriendship, friendship);

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

            try
            {
                await _context.SaveChangesAsync();

                return(await _context.Friendships.FindAsync(id));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!FriendshipExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw ex;
                }
            }
        }
示例#3
0
        public async Task <ActionResult <Application> > PutApplication(int id, Application application)
        {
            if (id != application.Id)
            {
                return(BadRequest());
            }

            var previousApplication = await _context.Applications.FindAsync(id);

            UpdateProperties(previousApplication, application);

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

            try
            {
                await _context.SaveChangesAsync();

                return(await _context.Applications.FindAsync(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
示例#4
0
        public async Task <ActionResult <Party> > PutParty(int id, Party party)
        {
            if (id != party.Id)
            {
                return(BadRequest());
            }

            var previousParty = await _context.Parties.FindAsync(id);

            UpdateProperties(previousParty, party);

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

            try
            {
                await _context.SaveChangesAsync();

                return(await _context.Parties.FindAsync(id));
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!PartyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw ex;
                }
            }
        }