public async Task <ActionResult> Post(MessageDTOin message) { if (await messageService.SubmitMessage(message)) { return(Ok(new { Message = "Message Sent" })); } return(BadRequest("UserBlocking prevents messaging!")); }
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); }