Beispiel #1
0
        public static Message CreateValidMessage(
            User user,
            MessageStateEnum stateEnum = MessageStateEnum.Published,
            string mind              = "Fake message.",
            string speech            = "",
            int amountOfFavourites   = 0,
            DateTime?creationDate    = null,
            Message quotedMessage    = null,
            Message commentedMessage = null)
        {
            IMessageStateRepository messageStateRepository = ServiceLocator.Current.GetInstance <IMessageStateRepository>();
            ILanguageRepository     laguageRepository      = ServiceLocator.Current.GetInstance <ILanguageRepository>();
            Language language = laguageRepository.FindByCode("PL");

            return(new Message
            {
                Id = Guid.NewGuid(),
                User = user,
                Mind = mind,
                MessageState = messageStateRepository.FindByEnum(stateEnum),
                AmountOfFavourites = amountOfFavourites,
                CreationDate = creationDate ?? DateTime.UtcNow,
                QuotedMessage = quotedMessage,
                CommentedMessage = commentedMessage,
                Speech = speech,
                Language = language
            });
        }
 private static void AddMessageState(IDatabaseContext context, MessageStateEnum messageStateEnum, string name)
 {
     if (!context.MessageStates.Any(x => x.MessageStateEnum == messageStateEnum))
     {
         context.MessageStates.Add(new MessageState {
             Name = name, MessageStateEnum = messageStateEnum, CreationDate = DateTime.UtcNow, Version = 1
         });
     }
 }
Beispiel #3
0
 public MessageState FindByEnum(MessageStateEnum messageStateEnum)
 {
     return(_messageStateRepository.FindByEnum(messageStateEnum));
 }
 public MessageState FindByEnum(MessageStateEnum messageStateEnum)
 {
     return(FindAll().FirstOrDefault(x => x.MessageStateEnum == messageStateEnum));
 }