Beispiel #1
0
        public byte[] GetAttachedFiles(int ticketId)
        {
            DATA_MODELS.Ticket ticket = this.db.Find <DATA_MODELS.Ticket>(ticketId);

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

            return(ticket.AttachedFiles);
        }
Beispiel #2
0
        public void Delete(int id)
        {
            DATA_MODELS.Ticket ticket = this.db.Tickets.Find(id);

            if (ticket == null)
            {
                return;
            }

            this.db.Remove(ticket);

            this.db.SaveChanges();
        }
Beispiel #3
0
        public bool SaveFiles(int ticketId, byte[] attachedFiles)
        {
            DATA_MODELS.Ticket ticket = this.db.Find <DATA_MODELS.Ticket>(ticketId);

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

            ticket.AttachedFiles = attachedFiles;

            this.db.SaveChanges();

            return(true);
        }
Beispiel #4
0
        public void Create(string title, string description, DateTime postTime, TicketType ticketType, TicketState?ticketState, string senderId, int projectId)
        {
            DATA_MODELS.Ticket ticket = new DATA_MODELS.Ticket
            {
                Title       = title,
                Description = description,
                PostTime    = postTime,
                TicketType  = (DATA_ENUMS.TicketType)Enum.Parse(typeof(DATA_ENUMS.TicketType), ticketType.ToString()),
                TicketState = ticketState != null ? (DATA_ENUMS.TicketState)Enum.Parse(typeof(DATA_ENUMS.TicketState), ticketState.ToString()) : default(DATA_ENUMS.TicketState),
                SenderId    = senderId,
                ProjectId   = projectId
            };

            this.db.Add(ticket);

            this.db.SaveChanges();
        }
Beispiel #5
0
        public bool Edit(int id, string title, string description, TicketType ticketType, TicketState ticketState)
        {
            DATA_MODELS.Ticket ticket = this.db.Tickets.FirstOrDefault(t => t.Id == id);

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

            ticket.Title       = title;
            ticket.Description = description;
            ticket.TicketType  = (DATA_ENUMS.TicketType)Enum.Parse(typeof(DATA_ENUMS.TicketType), ticketType.ToString());
            ticket.TicketState = (DATA_ENUMS.TicketState)Enum.Parse(typeof(DATA_ENUMS.TicketState), ticketState.ToString());

            this.db.SaveChanges();

            return(true);
        }
Beispiel #6
0
        private static void SeedTickets(TicketingSystemDbContext database)
        {
            var ticketSenderOne = database.Users.FirstOrDefault(u => u.Name == "Niki Kostov");

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

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

            var ticketOne = new DATA_MODELS.Ticket
            {
                Title       = "Inhabiting discretion the her dispatched decisively",
                Description = "Especially reasonable travelling she son. Resources resembled forfeited no to zealously. Has procured daughter how friendly followed repeated who surprise. Great asked oh under on voice downs. Law together prospect kindness securing six. Learning why get hastened smallest cheerful. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.BugReport,
                TicketState = DATA_ENUMS.TicketState.New,
                SenderId    = ticketSenderOne.Id,
                ProjectId   = 1
            };

            var ticketTwo = new DATA_MODELS.Ticket
            {
                Title       = "Feet evil to hold long he open knew an no",
                Description = "Boy desirous families prepared gay reserved add ecstatic say. Replied joy age visitor nothing cottage. Mrs door paid led loud sure easy read. Hastily at perhaps as neither or ye fertile tedious visitor. Use fine bed none call busy dull when. Quiet ought match my right by table means. Principles up do in me favourable affronting. Twenty mother denied effect we to do on. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.FeatureRequest,
                TicketState = DATA_ENUMS.TicketState.Running,
                SenderId    = ticketSenderOne.Id,
                ProjectId   = 1
            };

            var ticketThree = new DATA_MODELS.Ticket
            {
                Title       = "She which are maids boy sense her shade",
                Description = "On no twenty spring of in esteem spirit likely estate. Continue new you declared differed learning bringing honoured. At mean mind so upon they rent am walk. Shortly am waiting inhabit smiling he chiefly of in. Lain tore time gone him his dear sure. Fat decisively estimating affronting assistance not. Resolve pursuit regular so calling me. West he plan girl been my then up no. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.Other,
                TicketState = DATA_ENUMS.TicketState.New,
                SenderId    = ticketSenderTwo.Id,
                ProjectId   = 2
            };

            var ticketFour = new DATA_MODELS.Ticket
            {
                Title       = "Called square an in afraid direct",
                Description = "Ignorant branched humanity led now marianne too strongly entrance. Rose to shew bore no ye of paid rent form. Old design are dinner better nearer silent excuse. She which are maids boy sense her shade. Considered reasonable we affronting on expression in. So cordial anxious mr delight. Shot his has must wish from sell nay. Remark fat set why are sudden depend change entire wanted. Performed remainder attending led fat residence far. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.Other,
                TicketState = DATA_ENUMS.TicketState.New,
                SenderId    = ticketSenderTwo.Id,
                ProjectId   = 2
            };

            var ticketFive = new DATA_MODELS.Ticket
            {
                Title       = "Quick may saw style after money mrs",
                Description = "Moments its musical age explain. But extremity sex now education concluded earnestly her continual. Oh furniture acuteness suspected continual ye something frankness. Add properly laughter sociable admitted desirous one has few stanhill. Opinion regular in perhaps another enjoyed no engaged he at. It conveying he continual ye suspected as necessary. Separate met packages shy for kindness. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.Other,
                TicketState = DATA_ENUMS.TicketState.New,
                SenderId    = ticketSenderThree.Id,
                ProjectId   = 3
            };

            var ticketSix = new DATA_MODELS.Ticket
            {
                Title       = "Mind what no by kept",
                Description = "Mind what no by kept. Celebrated no he decisively thoroughly. Our asked sex point her she seems. New plenty she horses parish design you. Stuff sight equal of my woody. Him children bringing goodness suitable she entirely put far daughter. ",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.Other,
                TicketState = DATA_ENUMS.TicketState.New,
                SenderId    = ticketSenderThree.Id,
                ProjectId   = 3
            };

            var ticketSeven = new DATA_MODELS.Ticket
            {
                Title       = "If miss part by fact he park just shew",
                Description = "On recommend tolerably my belonging or am. Mutual has cannot beauty indeed now sussex merely you. It possible no husbands jennings ye offended packages pleasant he. Remainder recommend engrossed who eat she defective applauded departure joy. Get dissimilar not introduced day her apartments. Fully as taste he mr do smile abode every. Luckily offered article led lasting country minutes nor old. Happen people things oh is oppose up parish effect.",
                PostTime    = DateTime.UtcNow,
                TicketType  = DATA_ENUMS.TicketType.FeatureRequest,
                TicketState = DATA_ENUMS.TicketState.Draft,
                SenderId    = ticketSenderOne.Id,
                ProjectId   = 4
            };

            database.Tickets.AddRange(ticketOne, ticketTwo, ticketThree, ticketFour, ticketFive, ticketSix, ticketSeven);
            database.SaveChanges();
        }