// POST: api/Friendships
        public async Task <string> Post(FriendshipDto entity)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            var postId = await FriendshipGenericFacade.CreateAsync(entity);

            if (postId.Equals(0))
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            return($"Created Friendship with id: {postId}");
        }
示例#2
0
        public async Task <ActionResult> AddFriend(int id)
        {
            var user = await BasicUserFacade.GetUserByNickNameAsync(User.Identity.Name);

            var friendship = new FriendshipDto
            {
                User1Id         = user.Id,
                User2Id         = id,
                FriendshipStart = DateTime.Now.ToUniversalTime()
            };

            await FriendshipGenericFacade.CreateAsync(friendship);

            return(RedirectToAction("Index"));
        }