public async Task <IActionResult> PutVriend(long id, Vriend vriend)
        {
            if (id != vriend.VriendID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <ActionResult <Vriend> > PostVriend(Vriend vriend)
        {
            _context.Vrienden.Add(vriend);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVriend", new { id = vriend.VriendID }, vriend));
        }
示例#3
0
        public async Task <IActionResult> ConfirmFriend(int id)
        {
            Vriend vriend = await _context.Vrienden.FindAsync(id);

            if (vriend.bevestigd == false)
            {
                vriend.bevestigd = true;
            }

            _context.Entry(vriend).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VriendExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#4
0
        public async Task <ActionResult <Vriend> > PostVriend(Vriend vriend)
        {
            _context.Entry(vriend.Gebruiker1).State = EntityState.Modified;
            _context.Entry(vriend.Gebruiker2).State = EntityState.Modified;

            _context.Vrienden.Add(vriend);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVriend", new { id = vriend.Id }, vriend));
        }
示例#5
0
        public async Task <ActionResult <Vriend> > SendRequest()
        {
            GebruikerController gebruikerController = new GebruikerController(gebruikerService, _context);
            Vriend newVriend = new Vriend {
                Gebruiker1 = gebruikerController.gebruikerReceiveRequest, Gebruiker2 = gebruikerController.gebruikerSendRequest, Geaccepteerd = false
            };

            _context.Vrienden.Add(newVriend);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVriend", new { id = newVriend.Id }, newVriend));
        }
示例#6
0
        public async Task <IActionResult> UpdateVriend([FromRoute] long vriendID, [FromBody] Vriend vriend)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (vriendID != vriend.VriendID)
            {
                return(BadRequest());
            }
            var user = await _context.Users.Where(u => u.UserName == vriend.UserName).SingleOrDefaultAsync();

            var userName = User.Claims.FirstOrDefault(c => c.Type == "UserName").Value;
            var userID   = User.Claims.FirstOrDefault(c => c.Type == "UserID").Value;
            var ikZelf   = await _context.Vriend.Where(v => v.UserName == userName).SingleOrDefaultAsync();


            var vriendUser = await _context.VriendUser.Where(v => v.UserID == user.UserID).Where(s => s.VriendID == ikZelf.VriendID).SingleOrDefaultAsync();

            vriendUser.Status = true;

            var vriendUser2 = new VriendUser();

            vriendUser2.VriendID = vriend.VriendID;
            vriendUser2.UserID   = long.Parse(userID);
            vriendUser2.Status   = true;
            _context.VriendUser.Add(vriendUser2);
            await _context.SaveChangesAsync();

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

            return(NoContent());
        }
示例#7
0
        public List <Vriend> GetDataVriend(string query)
        {
            OracleCommand cmd = conn.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = query;
            OracleDataReader dr       = cmd.ExecuteReader();
            List <Vriend>    vrienden = new List <Vriend>();

            while (dr.Read())
            {
                Vriend v = new Vriend(dr.GetInt32(0), dr.GetInt32(1));
                vrienden.Add(v);
            }
            dr.Close();
            cmd.Dispose();
            return(vrienden);
        }
示例#8
0
        public async Task <IActionResult> PostVriend([FromBody] Vriend vriend)
        {
            var userID = User.Claims.FirstOrDefault(c => c.Type == "UserID").Value;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var vriendUser = new VriendUser();

            vriendUser.Vriend = vriend;
            vriendUser.UserID = long.Parse(userID);
            vriendUser.Status = false;
            _context.VriendUser.Add(vriendUser);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVriend", new { id = vriend.VriendID }, vriend));
        }
        public async Task <IActionResult> PostPollUser([FromBody] PollUser pollUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Vriend vriend = await _context.Vriend.Where(v => v.VriendID == pollUser.UserID).SingleOrDefaultAsync();

            User user = await _context.Users.Where(u => u.UserName == vriend.UserName).SingleOrDefaultAsync();

            PollUser juistPollUser = new PollUser();

            juistPollUser.PollID = pollUser.PollID;
            juistPollUser.UserID = user.UserID;

            _context.PollUser.Add(juistPollUser);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPollUser", new { id = juistPollUser.PollUserID }, juistPollUser));
        }
示例#10
0
        public async Task <IActionResult> PostUser([FromBody] User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            var vriend = new Vriend();

            vriend.Email    = user.Email;
            vriend.UserName = user.UserName;


            _context.Vriend.Add(vriend);
            _context.Users.Add(user);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUser", new { id = user.UserID }, user));
        }