// 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}"); }
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")); }