Exemple #1
0
        /// <summary>
        /// Render the gienv #script e-mail template.
        /// </summary>
        /// <param name="mail">text email message using the #script language within the message body and subject.</param>
        /// <param name="ticket">Ticket data to populate the variables that can be used within the template.</param>
        /// <returns>rendered template</returns>
        public static async Task <EmailMessage> RenderTicketMailAsync(
            EmailMessage mail, Models.Ticket ticket, string homepageUrl)
        {
            var context = new ScriptContext
            {
                PageFormats = { new PlainTextPageFormat() },
                Args        =
                {
                    ["FirstName"]        = ticket.FirstName,
                    ["LastName"]         = ticket.LastName,
                    ["TicketTypeName"]   = ticket.TicketType.Name,
                    ["TicketPrice"]      = ticket.TicketType.Price,
                    ["EventName"]        = ticket.Event.Name,
                    ["EventLocation"]    = ticket.Event.Location,
                    ["EventHomepageUrl"] = homepageUrl,
                    ["EventHost"]        = ticket.Event.Host
                }
            };

            context.Init();
            mail.Subject = await context.RenderScriptAsync(mail.Subject);

            mail.Body = await context.RenderScriptAsync(mail.Body);

            return(mail);
        }
        public IActionResult OnGet(int id)
        {
            var user = m_userManager.Users.Include(x => x.ApiKeys).FirstOrDefault(x => x.UserName == User.Identity.Name).ApiKeys.ToList();

            foreach (var item in user)
            {
                if (item.Source == Source.VSTS)
                {
                    var token = item.VSTStoken;

                    Value = m_VSTSService.GetProjects(token);
                }
            }


            Ticket = m_ticketService.GetTicketById(id);
            Input  = new InputModel()
            {
                TicketId = id
            };

            if (Ticket == null)
            {
                return(RedirectToPage("../Tickets/MyTickets"));
            }

            return(Page());
        }
Exemple #3
0
        public ActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                Models.Linhas newLinha = new Models.Linhas();
                Models.Ticket ticket   = new Models.Ticket();
                newLinha.Number      = number.Trim().ToLower();
                newLinha.Description = description.Trim().ToLower();
                ticket.ID            = TicketID;
                newLinha.Ticket      = ticket;

                if (Call.Calls.CreateLines(newLinha).Result)
                {
                    return(RedirectToPage("Linhas"));
                }
                else
                {
                    Message = "Erro ao realizar operação!";
                    return(Page());
                }
            }
            else
            {
                return(Page());
            }
        }
        public TicketAjouterPresenter(ITicketAjouterView view)
        {
            _view = view;

            _ticket = new Models.Ticket();
            _ticket.Contenu = new List<Models.TicketContenu>();
        }
        public TicketDetailsView(Models.Ticket ticket)
        {
            InitializeComponent();

            _ticket = ticket;
            _presenter = new TicketDetailsPresenter(this);
        }
        // Updates our current value with the values in the fields.
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid)
            {
                int.TryParse(Request.Form["TicketId"], out var ticketId);
                int.TryParse(Request.Form["LoggerId"], out var loggerId);
                var workerId = int.Parse(Request.Form["WorkerId"]);
                int.TryParse(Request.Form["StatusIndCd"], out var statusValue);
                var statusIndCd = (StatusIndCd)statusValue;
                _Title      = Request.Form["_Title"].ToString();
                Description = Request.Form["Description"].ToString();
                Resolution  = Request.Form["Resolution"].ToString();

                var ticketController = new TicketController(_configRoot);
                var updateTicket     =
                    new Models.Ticket(workerId,
                                      _Title,
                                      Description,
                                      Resolution,
                                      loggerId,
                                      statusIndCd,
                                      ticketId);

                if (await ticketController.Update(updateTicket))
                {
                    return(new RedirectToPageResult("Tickets"));
                }
            }

            return(Page());
        }
Exemple #7
0
        public async Task <IActionResult> OnPost()
        {
            var userId = HttpContext.Session.GetInt32("UserId");

            if (userId == null)
            {
                Response.Redirect("Login");
            }

            if (ModelState.IsValid)
            {
                var ticketController = new TicketController(_configRoot);
                var workerId         = int.Parse(Request.Form["WorkerId"]);
                _Title      = Request.Form["_Title"];
                Description = Request.Form["Description"];
                var loggerId = int.Parse(Request.Form["LoggerId"]);

                var ticket = new Models.Ticket(workerId, _Title, Description, null, loggerId, null, null);

                if (await ticketController.Insert(ticket))
                {
                    Response.Redirect("/Tickets");
                }
            }

            return(Page());
        }
Exemple #8
0
        public IActionResult Create(Models.Ticket t)
        {
            //load tickets.xml
            string      path = Request.PathBase + "App_Data/tickets.xml";
            XmlDocument doc  = new XmlDocument();

            if (System.IO.File.Exists(path))
            {
                //if file exists, just load it and create new ticket
                doc.Load(path);

                //create a new ticket
                XmlElement ticketXmlElement = _CreateTicketElement(doc, t);

                // get the root element
                doc.DocumentElement.AppendChild(ticketXmlElement);
            }
            else
            {
                //file doesn't exist, so create and create new ticket
                XmlNode dec = doc.CreateXmlDeclaration("1.0", "utf-8", "");
                doc.AppendChild(dec);
                XmlNode root = doc.CreateElement("tickets");

                //create a new ticket
                XmlElement ticketXmlElement = _CreateTicketElement(doc, t);
                root.AppendChild(ticketXmlElement);
                doc.AppendChild(root);
            }
            doc.Save(path);

            return(View());
        }
        public JsonResult GetTicket(int id)
        {
            using (var context = new Data.ApplicationDbContext()) {
                String      authUserId = User.GetClaim(OpenIdConnectConstants.Claims.Subject);
                Models.User authUser   = context.Users.AsNoTracking().FirstOrDefault(u => u.Id.ToString().Equals(authUserId));
                if (authUser == null)
                {
                    return(Json(new { status_code = 2, status = "User '" + authUserId + "' does not exist" }));
                }

                Models.Ticket ticket = context.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == id);
                if (ticket == null)
                {
                    return(Json(new { status_code = 2, status = "Ticket '" + id + "' does not exist" }));
                }
                if (authUser.Level >= 4)
                {
                    return(Json(new { status_code = 0, ticket }));
                }
                else
                {
                    Models.Permission permission = context.Permissions.AsNoTracking().FirstOrDefault(p => p.UserId == authUser.Id && p.SiteId == id);
                    if (permission == null || permission.Access == 0)
                    {
                        return(Json(new { status_code = 1, status = "User does not have permission to view this ticket" }));
                    }
                    return(Json(new { status_code = 0, ticket }));
                }
            }
        }
Exemple #10
0
        public ActionResult OnPost()
        {
            Models.LinhasAlter linhas = new Models.LinhasAlter();
            Models.Ticket      ticket = new Models.Ticket();
            linhas.ID          = lineID;
            linhas.Number      = number.Trim().ToUpper();
            linhas.Description = description.Trim().ToUpper();
            linhas.Alter_Date  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ticket.ID          = ticketID;
            ticket.Alter_Date  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            linhas.Ticket      = ticket;
            linhas.UserID      = Guid.Parse(HttpContext.Session.GetString("SessionUid"));

            if (ModelState.IsValid)
            {
                if (Call.Calls.EditLines(linhas).Result)
                {
                    return(RedirectToPage("Linhas"));
                }
                else
                {
                    Message = "Erro ao realizar operação!";
                    return(Page());
                }
            }
            else
            {
                return(Page());
            }
        }
Exemple #11
0
 public NewTicketViewModel()
 {
     SaveNewTicket    = new RelayCommand(SaveTicket);
     Ticket           = new Models.Ticket();
     DataTicket       = new DataAccessLayer.Ticket();
     ticketDataAccess = new TicketDataAccess();
 }
        public TicketModifierView(Models.Ticket ticket)
        {
            InitializeComponent();

            _ticket = ticket;

            _presenter = new TicketModifierPresenter(this);
        }
Exemple #13
0
        public async Task <ActionResult> CreateTicketAsync([FromBody] Models.Ticket ticket)
        {
            kitchenContext.Tickets.Add(ticket);

            await kitchenContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetTicketsAsync), new { id = ticket.Id }, null));
        }
        public int ReserveFlight(int userId, int flightId, List <ViewModel.ReseveFlightVM> model)
        {
            using (var tran = _db.Database.BeginTransaction())
            {
                Models.Reserve r = new Models.Reserve()
                {
                    ReserveDate = DateTime.Now,
                    UserId      = userId,
                };
                _db.Reserves.Add(r);
                _db.SaveChanges();
                try
                {
                    foreach (var item in model)
                    {
                        //به ازای هر یک از اطلاعات مسافران اگر آیدی یا کد ملی وجود داشته باشد همان را از دیتابیس می گیریم
                        // در صورتی که اطلاعات در دیتابیس وجود نداشته باشد آنرا میسازیم
                        var passenger = _db.Passengers.FirstOrDefault(p => p.NationalityCode == item.NationalityCode || p.Id == item.Id);


                        if (passenger == null)
                        {
                            passenger = new Models.Passenger()
                            {
                                Age             = item.Age,
                                NationalityCode = item.NationalityCode,
                                CreateDate      = DateTime.Now,
                                FullName        = item.FullName
                            };
                            _db.Passengers.Add(passenger);

                            _db.SaveChanges();
                        }

                        int?          maxCod = _db.Tickets.Any() ? _db.Tickets.Max(p => p.Code) : 0;
                        Models.Ticket t      = new Models.Ticket()
                        {
                            PassengerId = passenger.Id,
                            Code        = maxCod.HasValue ? maxCod.Value + 1 : 1,
                            ReseveId    = r.Id,
                            Price       = 1000,
                            FlightId    = flightId
                        };
                        _db.Tickets.Add(t);
                        _db.SaveChanges();
                    }

                    tran.Commit();

                    return(r.Id);
                }
                catch (System.Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            }
        }
 public ListofUserAndTicketViewModel()
 {
     TicketsList  = new List <Models.Ticket>();
     AssignList   = new List <SelectListItem>();
     PriorityList = new List <SelectListItem>();
     StatusList   = new List <SelectListItem>();
     Admin        = new Users();
     Tickets      = new Models.Ticket();
 }
        //interface actie - resultaat onPost (submit roept die aan)
        public IActionResult OnPost()
        {
            var ticket = new Models.Ticket()
            {
                TicketSubject   = Input.TicketSubject,
                TicketDetails   = Input.TicketDetails,
                TicketRequestor = User.Identity.Name,
                TicketDate      = DateTime.Now,
                PriorityType    = Input.TicketPriority,
                StatusType      = Models.Status.Open,
                ProductType     = Input.TicketProduct,
            };

            m_ticketService.AddTicket(ticket);
            m_ticketService.AddCategoryToTicket(ticket.TicketId, Input.Category);

            var user = new ApplicationUser {
                UserName = Input.TicketRequestor, Email = Input.TicketRequestor
            };
            var result = m_userManager.CreateAsync(user).Result;

            if (result.Succeeded)
            {
                //add user to role
                var test2 = m_userManager.AddToRoleAsync(user, "Customer").Result;
                //add notifcation settings
                var userNotifications = m_userManager.Users.Include(x => x.Notifications).FirstOrDefault(x => x.UserName == user.UserName);
                userNotifications.Notifications.Add(new Models.Notifications()
                {
                    TicketCreated = true,
                    TicketUpdate  = true,
                    NewArticle    = true,
                    NewDocument   = true
                });
                m_context.SaveChanges();
                //new account has been created
                //stuur een Email confirmatie mail  ....
                var code        = m_userManager.GenerateEmailConfirmationTokenAsync(user).Result;
                var callbackUrl = Url.EmailConfirmationNewTicketLink(user.Id, code, Request.Scheme);

                m_mailmanager.SendEmailConfirmationAsync(Input.TicketRequestor, callbackUrl, Input.TicketRequestor);

                // zorg ervoor dat de gebruiker hier ook zijn passwoord kan setten
            }
            else
            {
                //account already in DB
                //stuur mail dat er een ticket is aangemaakt
                SendMailTicketCreate(ticket.TicketId);
            }



            //na post van ticket, redirect naar my ticket lijst
            return(RedirectToPage("../Tickets/MyTickets"));
        }
Exemple #17
0
        public async Task <IActionResult> Post([FromBody] Models.Ticket nClient)
        {
            if (ModelState.IsValid)
            {
                var newClient = await uow.Tickets.Create(nClient).ConfigureAwait(false);

                return(Ok(newClient));
            }
            return(BadRequest());
        }
        public void TestMethod1()
        {
            Booking.Models.Ticket c   = new Models.Ticket(1, new Passenger());
            Booking.DB.DbTicket   dbT = new DB.DbTicket();

            Assert.AreNotEqual(c, dbT.Get(1));

            dbT.Create(c);

            Assert.AreEqual(c, dbT.Get(9999));
        }
Exemple #19
0
        public IActionResult Create()
        {
            var ticket  = new Models.Ticket();
            var message = new Models.Message();

            ticket.Messages = new List <Message>()
            {
                message
            };
            return(View(ticket));
        }
Exemple #20
0
        public async Task <IActionResult> Put(int id, [FromBody] Models.Ticket nClient)
        {
            if (ModelState.IsValid)
            {
                if (id == nClient.TicketId)
                {
                    await uow.Tickets.Update(nClient).ConfigureAwait(false);

                    return(Ok());
                }
            }
            return(BadRequest());
        }
Exemple #21
0
 public static void BookTicket(string IdSeat, ISession session)
 {
     if (!String.IsNullOrEmpty(IdSeat))
     {
         var cart   = SessionHelper.GetObjFromJson <SummaryBookingViewModel>(session, Common.SESSIONSUMMARY_NAME);
         var entity = new QUANLIXEContext();
         var ticket = new Models.Ticket()
         {
             IdSeat = IdSeat,
             IdCus  = cart.Customer.Passport,
             //Export=
         };
     }
 }
Exemple #22
0
        public void OnGet()
        {
            DataTable ticketsDT = Call.Calls.GetTickets().GetAwaiter().GetResult();

            foreach (DataRow row in ticketsDT.Rows)
            {
                tickets = new Models.Ticket();

                tickets.ID    = Guid.Parse(row.ItemArray[0].ToString());
                tickets.Price = decimal.Parse(row.ItemArray[1].ToString());

                tarifas.Add(tickets);
            }
        }
        public IActionResult OnPostCreate(int id)
        {
            var ticket = new Models.Ticket()
            {
                TicketSubject   = Input.TicketSubject,
                TicketDetails   = Input.TicketDetails,
                TicketRequestor = User.Identity.Name,
                TicketDate      = DateTime.Now,
                PriorityType    = Input.TicketPriority,
                StatusType      = Models.Status.Open,
                ProductType     = Input.TicketProduct
            };

            m_ticketService.AddTicket(ticket);

            var user = new ApplicationUser {
                UserName = Input.TicketRequestor, Email = Input.TicketRequestor
            };
            var result = m_userManager.CreateAsync(user).Result;

            if (result.Succeeded)
            {
                //add user to role
                var test2 = m_userManager.AddToRoleAsync(user, "Customer").Result;
                //new account has been created
                //stuur een Email confirmatie mail  ....
                var code        = m_userManager.GenerateEmailConfirmationTokenAsync(user).Result;
                var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                m_mailmanager.SendEmailConfirmationAsync(Input.TicketRequestor, callbackUrl, Input.TicketRequestor);

                // zorg ervoor dat de gebruiker hier ook zijn passwoord kan setten
            }
            else
            {
                //account already in DB
                //stuur mail dat er een ticket is aangemaakt
                SendMailTicketCreate(ticket.TicketId);
            }

            if (Input.Delete == true)
            {
                m_emailReceiver.DeleteMailTicket(id);
            }

            return(Redirect("../../Tickets/MyTickets"));
        }
Exemple #24
0
        public void PreencherListaLinhas(DataTable dt)
        {
            foreach (DataRow row in dt.Rows)
            {
                lines = new Models.Linhas();
                Models.Ticket ticket = new Models.Ticket();

                lines.ID          = Guid.Parse(row.ItemArray[0].ToString());
                lines.Number      = row.ItemArray[1].ToString();
                lines.Description = row.ItemArray[2].ToString();
                ticket.ID         = Guid.Parse(row.ItemArray[3].ToString());
                ticket.Price      = decimal.Parse(row.ItemArray[4].ToString());
                lines.Ticket      = ticket;

                linhas.Add(lines);
            }
        }
        public static DataAccessLayer.Entities.Ticket ModelTicketToEntityTicket(Models.Ticket modelTicket)
        {
            DataAccessLayer.Entities.Ticket entityTicket = new DataAccessLayer.Entities.Ticket()
            {
                Id            = modelTicket.Id,
                Card          = null,
                BuyingDate    = modelTicket.BuyingDate,
                Inserter      = null,
                IsDeleted     = modelTicket.IsDeleted,
                LastLoginDate = modelTicket.LastLoginDate,
                LoginsNum     = modelTicket.LoginsNum,
                Price         = modelTicket.Price,
                StartDate     = modelTicket.StartDate,
                Type          = null
            };

            return(entityTicket);
        }
Exemple #26
0
        private List <Models.Ticket> CrearTickets()
        {
            List <Models.Ticket> Tickets = new List <Models.Ticket>();

            Models.Ticket Ticket1 = new Models.Ticket();
            Ticket1.Aplicacion  = "SAP";
            Ticket1.Criticidad  = 1; //1 mas alto - 5 mas bajo
            Ticket1.Descripcion = "Al realizar un alta, el sistema muestra un error de conexiòn con la base de datos";
            Ticket1.Solicitante = "Juan Perez";
            Ticket1.Estado      = 1; //1=abierto 2=en correccion 3:cerrado
            Ticket1.NroTicket   = 1;

            Models.Ticket Ticket2 = new Models.Ticket();
            Ticket2.Aplicacion  = "Oracle";
            Ticket2.Criticidad  = 2; //1 mas alto - 5 mas bajo
            Ticket2.Descripcion = "Al realizar una instalacion del server, se detecta una falla";
            Ticket2.Solicitante = "Juan Perez";
            Ticket2.Estado      = 2; //1=abierto 2=en correccion 3:cerrado
            Ticket2.NroTicket   = 2;

            Models.Ticket Ticket3 = new Models.Ticket();
            Ticket3.Aplicacion  = "Reporte Gerencial";
            Ticket3.Criticidad  = 1; //1 mas alto - 5 mas bajo
            Ticket3.Descripcion = "Al solicitar la generaciòn del reporte no se ven datos";
            Ticket3.Solicitante = "Cristian Martinez";
            Ticket3.Estado      = 3; //1=abierto 2=en correccion 3:cerrado
            Ticket3.NroTicket   = 3;


            Models.Ticket Ticket4 = new Models.Ticket();
            Ticket4.Aplicacion  = "Liquidacion de sueldos";
            Ticket4.Criticidad  = 1; //1 mas alto - 5 mas bajo
            Ticket4.Descripcion = "al abrir el sistema, el mismo avisa que no hay empleados cargados";
            Ticket4.Solicitante = "Juana Perez";
            Ticket4.Estado      = 1; //1=abierto 2=en correccion 3:cerrado
            Ticket4.NroTicket   = 4;

            Tickets.Add(Ticket1);
            Tickets.Add(Ticket2);
            Tickets.Add(Ticket3);
            // Tickets.Add(Ticket4);
            return(Tickets);
        }
        /// <summary>
        /// Creates an anonymous object with all info relating to a ticket, instead of just the essential information.
        ///
        /// Normally, tickets only have ID values and not string values because they are used internally and can be
        /// converted on the server as needed, but the client side doesn't have direct access to all the internal data
        /// the server does (unless accessed via multiple routes, which would waste time).
        ///
        /// tl;dr This method just gives info the client would need about a ticket.
        /// </summary>
        /// <remarks>Assumes ticket is valid</remarks>
        /// <param name="ticket">The ticket to pull all information from</param>
        /// <returns>An anonymous object with extra information about a given ticket</returns>
        private object FullTicketInfo(Models.Ticket ticket)
        {
            using (var context = new Data.ApplicationDbContext()) {
                Models.Site siteTicket     = context.Sites.AsNoTracking().FirstOrDefault(s => s.SiteId == ticket.SiteId);
                Models.User ticketCreator  = context.Users.AsNoTracking().FirstOrDefault(c => c.Id == ticket.CreatedBy);
                Models.User ticketAssignee = null;
                if (ticket.AssignedTo.HasValue)
                {
                    ticketAssignee = context.Users.AsNoTracking().FirstOrDefault(a => a.Id == ticket.AssignedTo);
                }

                return(new {
                    Id = ticket.Id,
                    SiteId = ticket.SiteId,
                    Subject = ticket.Subject,
                    Comments = ticket.Comments,
                    Priority = (int)ticket.Priority,
                    PriorityName = ticket.Priority.ToString().Replace('_', ' '),
                    Status = (int)ticket.Status,
                    StatusName = ticket.Status.ToString().Replace('_', ' '),
                    Category = (int)ticket.Category,
                    CategoryName = ticket.Category.ToString().Replace('_', ' '),
                    SiteName = siteTicket != null ? siteTicket.SiteName : "",
                    AssignedTo = ticket.AssignedTo,
                    CreatedBy = ticket.CreatedBy,
                    CreatedDate = ticket.CreatedDate,
                    Creator = ticketCreator != null ?
                              new {
                        UserName = ticketCreator.UserName,
                        FName = ticketCreator.FName,
                        LName = ticketCreator.LName
                    } : null,
                    Assignee = ticketAssignee != null ?
                               new {
                        UserName = ticketAssignee.UserName,
                        FName = ticketAssignee.FName,
                        LName = ticketAssignee.LName
                    } : null,
                    DueDate = ticket.DueDate,
                    LastUpdated = ticket.LastUpdated
                });
            }
        }
Exemple #28
0
        public ViewResult SellTicket(Models.Ticket t)
        {
            if (ModelState.IsValid)
            {
                ServiceReference1.Ticket ticket = new ServiceReference1.Ticket();
                ticket.Section   = t.Section;
                ticket.Row       = t.Row;
                ticket.Seat      = t.Seat;
                ticket.Admission = t.Admission;
                ticket.Name      = t.Name;
                ticket.Date      = t.Date;
                ticket.Price     = t.Price;

                client.InsertTicket(ticket);
                ViewBag.ListTickets = client.DisplayAllTickets();
                return(View("Ticket"));
            }
            return(View());
        }
 //-----------------------------------TICKET--------------------------------------------------------
 public static Models.Ticket EntityTicketToModelTicket(DataAccessLayer.Entities.Ticket entityTicket)
 {
     Models.Ticket modelTicket = new Models.Ticket
     {
         Id            = entityTicket.Id,
         ClientId      = entityTicket.Card.Id,
         ClientName    = entityTicket.Card.FirstName + " " + entityTicket.Card.LastName,
         BuyingDate    = entityTicket.BuyingDate,
         StartDate     = entityTicket.StartDate,
         LastLoginDate = entityTicket.LastLoginDate,
         LoginsNum     = entityTicket.LoginsNum,
         Price         = entityTicket.Price,
         EmployeeName  = entityTicket.Inserter.Name,
         IsDeleted     = entityTicket.IsDeleted,
         TicketName    = entityTicket.Type.Name
     };
     modelTicket.EndDate          = entityTicket.Type.DayNum != 0 ? modelTicket.StartDate.AddDays(entityTicket.Type.DayNum) : entityTicket.BuyingDate;//mivel muszaj idopontot megadjak ezert berakom a vasarlas pillanatat
     modelTicket.RemaningLoginNum = entityTicket.Type.OccasionNum != 0 ? entityTicket.Type.OccasionNum - modelTicket.LoginsNum : -1;
     return(modelTicket);
 }
        public JsonResult UpdateTicket([FromBody] Models.Ticket ticket)
        {
            using (var context = new Data.ApplicationDbContext()) {
                String      authUserId = User.GetClaim(OpenIdConnectConstants.Claims.Subject);
                Models.User authUser   = context.Users.AsNoTracking().FirstOrDefault(u => u.Id.ToString().Equals(authUserId));
                if (authUser == null)
                {
                    return(Json(new { status_code = 2, status = "User '" + authUserId + "' does not exist" }));
                }

                Models.Ticket dbTicket = context.Tickets.FirstOrDefault(t => t.Id == ticket.Id);

                if (dbTicket == null)
                {
                    return(Json(new { status_code = 2, status = "Ticket '" + ticket.Id + "' does not exist" }));
                }
                else if (ticket.Comments.Length == 0)
                {
                    return(Json(new { status_code = 4, status = "User must enter ticket comments" }));
                }
                else if (ticket.Priority < 0 || (int)ticket.Priority > 3)
                {
                    return(Json(new { status_code = 4, status = "Invalid ticket priority" }));
                }
                else if (ticket.Status < 0 || (int)ticket.Status > 4)
                {
                    return(Json(new { status_code = 4, status = "Invalid ticket status" }));
                }

                if (ticket.Status == Models.Ticket.TicketStatus.NEW && ticket.AssignedTo.HasValue)
                {
                    ticket.Status = Models.Ticket.TicketStatus.OPEN;
                }

                dbTicket.LastUpdated = DateTime.UtcNow;
                dbTicket.Copy(ticket);
                context.SaveChanges();
            }

            return(Json(new { status_code = 0, ticket = FullTicketInfo(ticket) }));
        }
        public JsonResult CreateTicket([FromBody] Models.Ticket ticket)
        {
            using (var context = new Data.ApplicationDbContext()) {
                String      authUserId = User.GetClaim(OpenIdConnectConstants.Claims.Subject);
                Models.User authUser   = context.Users.AsNoTracking().FirstOrDefault(u => u.Id.ToString().Equals(authUserId));
                if (authUser == null)
                {
                    return(Json(new { status_code = 2, status = "User '" + authUserId + "' does not exist" }));
                }

                if (ticket.Comments.Length == 0)
                {
                    return(Json(new { status_code = 4, status = "User must enter ticket comments" }));
                }
                else if (ticket.Priority < 0 || (int)ticket.Priority > 3)
                {
                    ticket.Priority = Models.Ticket.PriortiyLevel.LOW;
                }
                else if (ticket.Status < 0 || (int)ticket.Status > 4)
                {
                    ticket.Status = Models.Ticket.TicketStatus.NEW;
                }
                else if (ticket.SiteId <= 0)
                {
                    return(Json(new { status_code = 4, status = "Ticket must be assigned to a site" }));
                }

                ticket.CreatedBy   = authUser.Id;
                ticket.CreatedDate = DateTime.UtcNow;

                if (ticket.AssignedTo.HasValue)
                {
                    ticket.Status = Models.Ticket.TicketStatus.OPEN;
                }

                context.Tickets.Add(ticket);
                context.SaveChanges();
            }
            return(Json(new { status_code = 0, ticket = FullTicketInfo(ticket) }));
        }
        public JsonResult DeleteTicket(int id)
        {
            using (var context = new Data.ApplicationDbContext()) {
                String      authUserId = User.GetClaim(OpenIdConnectConstants.Claims.Subject);
                Models.User authUser   = context.Users.AsNoTracking().FirstOrDefault(u => u.Id.ToString().Equals(authUserId));
                if (authUser == null)
                {
                    return(Json(new { status_code = 2, status = "User '" + authUserId + "' does not exist" }));
                }

                Models.Ticket ticket = context.Tickets.FirstOrDefault(t => t.Id == id);
                if (ticket == null)
                {
                    return(Json(new { status_code = 2, status = "Ticket with Id '" + id + "' does not exist" }));
                }

                context.Tickets.Remove(ticket);
                context.SaveChanges();

                return(Json(new { status_code = 0 }));
            }
        }
Exemple #33
0
        public void OnGet(Guid id)
        {
            DataTable lineDt    = Call.Calls.GetLinesById(id).GetAwaiter().GetResult();
            DataTable ticketsDt = Call.Calls.GetTickets().GetAwaiter().GetResult();

            foreach (DataRow row in lineDt.Rows)
            {
                lineID      = Guid.Parse(row.ItemArray[0].ToString());
                number      = row.ItemArray[1].ToString().ToUpper();
                description = row.ItemArray[2].ToString().ToUpper();
            }

            foreach (DataRow row in ticketsDt.Rows)
            {
                Models.Ticket ticket = new Models.Ticket();

                ticket.ID    = Guid.Parse(row.ItemArray[0].ToString());
                ticket.Price = decimal.Parse(row.ItemArray[1].ToString());

                tickets.Add(ticket);
            }
        }
        public TicketDetailsPresenter(ITicketDetailsView view)
        {
            _view = view;

            _ticket = TicketDAO.Get(_view.Ticket.Num);
        }
        public TicketModifierPresenter(ITicketModifierView view)
        {
            _view = view;

            _ticket = TicketDAO.Get(_view.Ticket.Num);
        }