public IActionResult Edit(int id)
        {
            Ticket ticket = _ticketRepository.GetTicketById(id);

            TicketRecord _record = new TicketRecord()
            {
                TicketId          = ticket.TicketId,
                TicketDescription = ticket.Description,
                TicketUpdatedTime = ticket.TicketUpdated,
                Status            = ticket.Status,
                Priority          = ticket.Priority,
                ProjectId         = ticket.ProjectId,
                TicketName        = ticket.Name
            };

            _ticketRecordRepository.CreateRecord(_record);
            TicketEditViewModel ticektEditViewModel = new TicketEditViewModel()
            {
                TicketId      = ticket.TicketId,
                record        = _record,
                Name          = ticket.Name,
                TicketCreated = ticket.TicketCreated,
                TicketUpdated = ticket.TicketUpdated,
                Type          = ticket.Type,
                ProjectId     = ticket.ProjectId,
                Priority      = ticket.Priority,
                Status        = ticket.Status,
                Project       = ticket.Project,
                Description   = ticket.Description,
            };

            return(View(ticektEditViewModel));
        }
        private void metroTile3_Click(object sender, EventArgs e)
        {
            TicketRecord form = new TicketRecord();

            this.Hide();
            form.FormClosed += new FormClosedEventHandler(delegate { Close(); });
            form.Show();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Submits a ticket to the system
        /// </summary>
        /// <param name="category">The category of the ticket</param>
        /// <param name="description">The description inside the ticket</param>
        /// <returns>Whether the ticket was saved or not</returns>
        public async Task <bool> SubmitTicketAsync(Constants.TicketCategories category, string description)
        {
            TicketRecord ticketRecord = new TicketRecord(TimeUtilityService.CurrentUnixTime(),
                                                         category.ToString(),
                                                         Constants.TicketStatuses.Unresolved.ToString(),
                                                         Constants.TicketFlagColors.None.ToString(),
                                                         description);
            await ticketDAO.CreateAsync(ticketRecord);

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the ticket to the data source.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <param name="dispatcher">The dispatcher to use to alter the collection.</param>
        /// <returns></returns>
        public bool AddTicket(ITicket ticket, Dispatcher dispatcher = null)
        {
            TicketRecord newTicket = new TicketRecord();

            if (ticket.Id > 0)
            {
                newTicket.Id = ticket.Id;
            }
            newTicket.Street         = ticket.Street;
            newTicket.City           = ticket.City;
            newTicket.Code           = ticket.Code;
            newTicket.EMail          = ticket.EMail;
            newTicket.IsOnlineTicket = ticket.IsOnlineTicket;
            newTicket.IsRedeemed     = ticket.IsRedeemed;
            newTicket.Name           = ticket.Name;
            newTicket.Phone          = ticket.Phone;
            newTicket.RedeemDate     = ticket.RedeemDate;
            newTicket.Type           = ticket.Type;
            newTicket.Zip            = ticket.Zip;

            try
            {
                using (new SessionScope())
                {
                    newTicket.Create();
                }
            }
            catch { return(false); }

            Action add = delegate()
            {
                AllTickets.Add(newTicket);
                UpdateActiveTickets();
            };

            if (dispatcher == null)
            {
                add();
            }
            else
            {
                dispatcher.Invoke(add);
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("TicketCount"));
                PropertyChanged(this, new PropertyChangedEventArgs("RedeemedCount"));
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates a ticket's flag color
        /// </summary>
        /// <param name="ticketID">The id of the ticket</param>
        /// <param name="newFlagColor">The new flag color to use</param>
        /// <returns>Whether the flag color succesfully changed or not</returns>
        public async Task <bool> UpdateTicketFlagColorAsync(long ticketID, Constants.TicketFlagColors newFlagColor)
        {
            // Make sure the ticket exists first
            bool ticketExists = await ticketDAO.CheckTicketExistenceAsync(ticketID);

            if (!ticketExists)
            {
                throw new ArgumentException(Constants.TicketUpdateNotExists);
            }

            // Update the ticket
            TicketRecord ticketRecord = new TicketRecord(ticketID, null, null, newFlagColor.ToString(), null);
            await ticketDAO.UpdateAsync(ticketRecord);

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Updates a ticket's read status
        /// </summary>
        /// <param name="ticketID">The id of the ticket</param>
        /// <param name="newReadStatus">The new read status to use</param>
        /// <returns>Whether the read status succesfully changed or not</returns>
        public async Task <bool> UpdateTicketReadStatusAsync(long ticketID, bool newReadStatus)
        {
            // Make sure the ticket exists first
            bool ticketExists = await ticketDAO.CheckTicketExistenceAsync(ticketID);

            if (!ticketExists)
            {
                throw new ArgumentException(Constants.TicketUpdateNotExists);
            }

            // Update the ticket
            TicketRecord ticketRecord = new TicketRecord(ticketID, null, null, null, null, newReadStatus);
            await ticketDAO.UpdateAsync(ticketRecord);

            return(true);
        }
        public void CreateOrder()
        {
            var optionsBuilder = new DbContextOptionsBuilder <TicketContext>();

            using (TicketContext context = new TicketContext(optionsBuilder.Options))
            {
                var order = new TicketRecord()
                {
                    Name      = Parking.Name,
                    VehicleID = Parking.VehicleID,
                    StartTime = Parking.StartTime,
                    EndTime   = Parking.Endtime,
                    OccupationTimeInMinutes = OccupationTime,
                    AmountToPay             = TicketCost,
                    ParkingSpot             = new Random().Next(1, 30),
                };

                context.Add(order);
                context.SaveChanges();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Clears this datasource from all tickets.
        /// </summary>
        /// <param name="createBackup">if set to <c>true</c> a backup will be created.</param>
        /// <returns></returns>
        public bool Clear(bool createBackup = true)
        {
            if (createBackup)
            {
                File.Copy(Filename, Filename.Replace(Path.GetExtension(Filename), "_" + DateTime.Now.ToString("yyyyMddHHmm") + Path.GetExtension(Filename)), true);
            }
            TicketRecord.DeleteAll();

            AllTickets = new ObservableCollection <ITicket>();
            AllTickets.CollectionChanged += new NotifyCollectionChangedEventHandler(Tickets_CollectionChanged);
            UpdateActiveTickets();

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("AllTickets"));
                PropertyChanged(this, new PropertyChangedEventArgs("ActiveTickets"));
                PropertyChanged(this, new PropertyChangedEventArgs("TicketCount"));
                PropertyChanged(this, new PropertyChangedEventArgs("RedeemedCount"));
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Redeems the ticket.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public IRedeemResult RedeemTicket(int id)
        {
            SqlCeRedeemResult result = new SqlCeRedeemResult();

            TicketRecord ticket = GetTicket(id) as TicketRecord;

            if (ticket == null)
            {
                result.Type  = RedeemResultType.NotRedeemed;
                result.Error = "UNKNOW TICKET ID!";
            }
            else if (ticket.IsRedeemed)
            {
                result.Type = RedeemResultType.AlreadyRedeemed;
            }
            else
            {
                ticket.IsRedeemed = true;
                ticket.RedeemDate = DateTime.Now;
                try
                {
                    ticket.Save();
                    result.Type = RedeemResultType.Redeemed;
                }
                catch (Exception exp)
                {
                    result.Type  = RedeemResultType.NotRedeemed;
                    result.Error = exp.Message;
                }
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("RedeemedCount"));
            }

            return(result);
        }
Exemplo n.º 10
0
        public void Seed()
        {
            if (_context.Department.Any() || _context.User.Any() || _context.TicketRecord.Any())
            {
                return;
            }

            Department d1 = new Department(1, "Estudante");
            Department d2 = new Department(2, "Idoso");
            Department d3 = new Department(3, "Comum");

            User s1 = new User(1, "Renan Jashchenko", "*****@*****.**", new DateTime(1995, 8, 20), d3);
            User s2 = new User(2, "Ana Lúcia Cox", "*****@*****.**", new DateTime(1994, 9, 12), d1);

            TicketRecord tr1 = new TicketRecord(1, new DateTime(2019, 9, 20), 1, Models.Enums.TicketStatus.Pending, s1);
            TicketRecord tr2 = new TicketRecord(2, new DateTime(2019, 9, 20), 1, Models.Enums.TicketStatus.Billed, s2);

            _context.Department.AddRange(d1, d2, d3);
            _context.User.AddRange(s1, s2);
            _context.TicketRecord.AddRange(tr1, tr2);

            _context.SaveChanges();
        }
Exemplo n.º 11
0
 public IActionResult Create(TicketRecord ticketRecord)
 {
     _ticketRecordService.Insert(ticketRecord);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 12
0
 public void Insert(TicketRecord obj)
 {
     _context.Add(obj);
     _context.SaveChanges();
 }