Пример #1
0
        public bool DeleteFriend(FriendsDetail model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Friends
                    .Single(e => e.FriendUserId == model.FriendUserId && e.MyUserId == model.MyUserId);
                ctx.Friends.Remove(entity);

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult FriendsDelete(FriendsDetail model)
        {
            if (model is null)
            {
                return(BadRequest());
            }
            if (ModelState.IsValid)
            {
                var friendIsDeleted = friendsService.DeleteFriend(model);
                if (friendIsDeleted == true)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }

            return(BadRequest(ModelState));
        }