Exemplo n.º 1
0
        public async Task <IActionResult> DeleteRequest(int MateId)
        {
            UserMates userMates = getContext().UserMates.FirstOrDefault(w => w.UserId == MateId);

            getContext().Remove(userMates);
            await getContext().SaveChangesAsync();

            return(Json(true));
        }
Exemplo n.º 2
0
        public IActionResult GetFriendState(int Id)
        {
            int?      userId    = HttpContext.Session.GetInt32("id");
            UserMates userMates = getContext().UserMates.FirstOrDefault(w => w.UserId == (int)userId && w.MateId == Id);

            if (userMates == null)
            {
                userMates = new UserMates();
            }
            return(Json((int)userMates.State));
        }
Exemplo n.º 3
0
        public async Task <bool> RemoveFriend(int uid, int mid)
        {
            UserMates usm1 = await getContext().UserMates.FirstOrDefaultAsync(w => w.UserId == uid && w.MateId == mid);

            UserMates usm2 = await getContext().UserMates.FirstOrDefaultAsync(w => w.UserId == mid && w.MateId == uid);

            getContext().Remove(usm1);
            getContext().Remove(usm2);
            await getContext().SaveChangesAsync();

            return(true);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AcceptRequest(int MateId)
        {
            UserMates userMates1 = getContext().UserMates.FirstOrDefault(w => w.UserId == MateId);

            userMates1.State = State.Friend;
            getContext().Update(userMates1);
            UserMates userMates2 = new UserMates
            {
                UserId = userMates1.MateId,
                MateId = userMates1.UserId,
                State  = State.Friend
            };

            getContext().Add(userMates2);
            await getContext().SaveChangesAsync();

            return(Json(true));
        }