Exemplo n.º 1
0
        // 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}");
        }
Exemplo n.º 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"));
        }