コード例 #1
0
 public async Task <ActionResult> Post(MessageDTOin message)
 {
     if (await messageService.SubmitMessage(message))
     {
         return(Ok(new { Message = "Message Sent" }));
     }
     return(BadRequest("UserBlocking prevents messaging!"));
 }
コード例 #2
0
        public async Task <bool> SubmitMessage(MessageDTOin message)
        {
            var blockingPresent = await blockingRepo.All().FirstOrDefaultAsync(x => !x.IsDeleted && x.DefenderId == message.RecieverId && x.IrritatorId == message.SenderId);

            if (blockingPresent != null)
            {
                return(false);                         //not allowed to recieve messages from blocked users!
            }
            Message newMsg = mapper.Map <Message>(message);

            await messageRepo.AddAssync(newMsg);

            await messageRepo.SaveChangesAsync();

            return(true);
        }