Beispiel #1
0
        public async Task <string> Like(int userId, int recipientId)
        {
            var like = await _dataAccess.GetLike(userId, recipientId);

            if (like != null)
            {
                _dataAccess.Delete(like);
                if (await _dataAccess.SaveAll())
                {
                    return("Ok");
                }
            }

            if (await _dataAccess.GetUser(recipientId, false) == null)
            {
                return(null);
            }

            like = new Like
            {
                LikerId = userId,
                LikeeId = recipientId
            };

            _dataAccess.Add <Like>(like);

            if (await _dataAccess.SaveAll())
            {
                return("Ok");
            }

            return("Failed to Like User");
        }
Beispiel #2
0
        public async Task <Message> CreateMessage(int userid, MessageForCreactionDto messageForCreaction)
        {
            messageForCreaction.SenderId = userid;
            var recipient = await _business.GetUser(userid, userid);

            if (recipient == null)
            {
                return(null);
            }

            var message = _mapper.Map <Message>(messageForCreaction);

            _dataAccess.Add(message);

            if (await _dataAccess.SaveAll())
            {
                return(message);
            }
            else
            {
                throw new Exception("Creating the message failed on save");
            }
        }