Exemple #1
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            var person = await _ChataloRepository.GetPersonForClaimsPrincipalAsync(Context.User);

            _PersonsOnline.Remove(person.PersonId);
            await Clients.All.SendAsync("UserLeft", person.PersonId);

            await base.OnDisconnectedAsync(exception);
        }
        public async Task <IActionResult> Add([FromBody] DiscussionModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Summary", "Failed adding discussion");
                return(BadRequest(ModelState));
            }
            var person = await _Repository.GetPersonForClaimsPrincipalAsync(this.User);

            var discussion = model.ToDiscussion();

            discussion.CreatedByPersonId = person.PersonId;
            var addedDiscussion = await _Repository.AddDiscussionAsync(discussion);

            return(new OkObjectResult(addedDiscussion.ToDiscussionModel()));
        }
Exemple #3
0
        public async Task <IActionResult> Add([FromBody] PostModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Summary", "Failed adding post");
                return(BadRequest(ModelState));
            }
            var person = await _Repository.GetPersonForClaimsPrincipalAsync(this.User);

            var post = model.ToPost();

            post.CreatedByPersonId = person.PersonId;
            var addedPost = await _Repository.AddPostAsync(post);

            return(new OkObjectResult(addedPost.ToPostModel()));
        }