示例#1
0
        public byte[] GetAttachedFiles(int id)
        {
            DATA_MODELS.Message message = this.db.Find <DATA_MODELS.Message>(id);

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

            return(message.AttachedFiles);
        }
示例#2
0
        public bool SaveFiles(int messageId, byte[] attachedFiles)
        {
            DATA_MODELS.Message message = this.db.Find <DATA_MODELS.Message>(messageId);

            if (message == null)
            {
                return(false);
            }

            message.AttachedFiles = attachedFiles;

            this.db.SaveChanges();

            return(true);
        }
示例#3
0
        public void Create(string content, DateTime postTime, MessageState?state, int ticketId, string authorId)
        {
            DATA_MODELS.Message message = new DATA_MODELS.Message
            {
                Content  = content,
                PostDate = postTime,
                State    = state != null ? (DATA_ENUMS.MessageState)Enum.Parse(typeof(DATA_ENUMS.MessageState), state.ToString()) : default(DATA_ENUMS.MessageState),
                TicketId = ticketId,
                AuthorId = authorId
            };

            this.db.Add(message);

            this.db.SaveChanges();
        }
示例#4
0
        private static void SeedMessages(TicketingSystemDbContext database)
        {
            var messagetSenderOne = database.Users.FirstOrDefault(u => u.Name == "Niki Kostov");

            var messagetSenderTwo = database.Users.FirstOrDefault(u => u.Name == "Vasil Georgiev");

            var messagetSenderThree = database.Users.FirstOrDefault(u => u.Name == "Stamo Ivanov");

            var messageOne = new DATA_MODELS.Message
            {
                Content  = "Dissuade ecstatic and properly saw entirely sir why laughter endeavor. In on my jointure horrible margaret suitable he followed speedily. Indeed vanity excuse or mr lovers of on. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 1,
                AuthorId = messagetSenderTwo.Id
            };

            var messageTwo = new DATA_MODELS.Message
            {
                Content  = "By impossible of in difficulty discovered celebrated ye. Justice joy manners boy met resolve produce. Bed head loud next plan rent had easy add him. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 3,
                AuthorId = messagetSenderTwo.Id
            };

            var messageThree = new DATA_MODELS.Message
            {
                Content  = "Esteem my advice it an excuse enable. Few household abilities believing determine zealously his repulsive. To open draw dear be by side like. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 3,
                AuthorId = messagetSenderThree.Id
            };

            var messageFour = new DATA_MODELS.Message
            {
                Content  = "Announcing of invitation principles in. Cold in late or deal. Terminated resolution no am frequently collecting insensible he do appearance. Projection invitation affronting admiration if no on or. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 2,
                AuthorId = messagetSenderThree.Id
            };

            var messageFive = new DATA_MODELS.Message
            {
                Content  = "You fully seems stand nay own point walls. Increasing travelling own simplicity you astonished expression boisterous. Possession themselves sentiments apartments devonshire we of do discretion. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 4,
                AuthorId = messagetSenderOne.Id
            };

            var messageSix = new DATA_MODELS.Message
            {
                Content  = "Am increasing at contrasted in favourable he considered astonished. As if made held in an shot. By it enough to valley desire do. Mrs chief great maids these which are ham match she. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 5,
                AuthorId = messagetSenderOne.Id
            };

            var messageSeven = new DATA_MODELS.Message
            {
                Content  = "Boisterous he on understood attachment as entreaties ye devonshire. In mile an form snug were been sell. Hastened admitted joy nor absolute gay its. ",
                PostDate = DateTime.UtcNow,
                State    = DATA_ENUMS.MessageState.Published,
                TicketId = 6,
                AuthorId = messagetSenderTwo.Id
            };

            database.Messages.AddRange(messageOne, messageTwo, messageThree, messageFour, messageFive, messageSix, messageSeven);
            database.SaveChanges();
        }