/// <summary>
        ///     Funcion para insertar un nuevo elemento en la tabla historial
        /// </summary>
        /// <param name="customerLocation">Ubicacion del solicitante</param>
        /// <param name="employeeName">Nombre del solicitante</param>
        /// <param name="ticketRecord">Nuevo objeto para ser insertado en la base de datos </param>
        /// <param name="ticketId">Id del ticket a actualizar</param>
        /// <param name="customerEmail">Correo del solicitante</param>
        /// <param name="customerExt">Extension del solicitante</param>
        /// <param name="customerPhone">Telefono del solicitante</param>
        /// <param name="customerArea">Area del solicitante</param>
        /// <returns>Success booleano</returns>
        public TicketRegisterResult UpdateTicket(long ticketId, string customerEmail, int customerExt,
                                                 string customerPhone, string customerArea,
                                                 string customerLocation, string employeeName, TK_DT_RECORDS ticketRecord)
        {
            var result = new TicketRegisterResult();

            using (var db = new dbGoldenTicket())
            {
                if (!ticketRecord.TK_BT_EMPLOYEES_ID.IsNullOrWhiteSpace())
                {
                    var employee = new TK_BT_EMPLOYEES
                    {
                        TK_BT_EMPLOYEES_ID = ticketRecord.TK_BT_EMPLOYEES_ID,
                        FULLNAME           = employeeName
                    };

                    var employeeAux = new EmployeeRegister();
                    employeeAux.UpdateEmployee(employee);
                }

                // Actualizo la informacion de la tabla ticket
                var ticket = (
                    from tblTicket in db.TK_HD_TICKETS
                    where tblTicket.TK_HD_TICKETS_ID == ticketId
                    select tblTicket
                    ).SingleOrDefault();

                if (ticket != null)
                {
                    ticket.CUSTOMER_EMAIL     = customerEmail;
                    ticket.CUSTOMER_EXTENSION = customerExt;
                    ticket.CUSTOMER_AREA      = customerArea;
                    ticket.CUSTOMER_PHONE     = customerPhone;
                    ticket.CUSTOMER_LOCATION  = customerLocation;

                    db.SaveChanges();

                    result.CustomerEmail    = ticket.CUSTOMER_EMAIL;
                    result.CustomerFullName = ticket.CUSTOMER_FULLNAME;
                    result.FolioNewTicket   = ticket.FOLIO;
                    result.Content          = ticket.CONTENT;
                    result.Title            = ticket.TITLE;
                    result.IdNewTicket      = ticket.TK_HD_TICKETS_ID;

                    ticketRecord.TK_DT_RECORDS_ID = GenerateRecordId(ticketRecord.TK_HD_TICKETS_ID);
                    db.TK_DT_RECORDS.Add(ticketRecord);

                    result.Status   = ticketRecord.TK_CT_STATUS_ID;
                    result.Employee = ticketRecord.TK_BT_EMPLOYEES_ID;
                    result.Note     = ticketRecord.NOTE;

                    db.SaveChanges();
                }

                result.Success = true;
                result.Message = "op_exitosa";
            }

            return(result);
        }
        /// <summary>
        ///     Agrega un nuevo registro en el historial de un ticket
        /// </summary>
        /// <param name="ticketRecord">Objeto con la informacion a agregar en el historial del ticket</param>
        /// <returns>TicketRegisterResult con la secuencia del nuevo registro</returns>
        public TicketRegisterResult UpdateRecord(TK_DT_RECORDS ticketRecord)
        {
            var result = new TicketRegisterResult();

            using (var db = new dbGoldenTicket())
            {
                ticketRecord.TK_DT_RECORDS_ID = GenerateRecordId(ticketRecord.TK_HD_TICKETS_ID);
                db.TK_DT_RECORDS.Add(ticketRecord);
                db.SaveChanges();

                result.SequenceNewTicket = ticketRecord.TK_DT_RECORDS_ID;
                result.Success           = true;
                result.Message           = "op_exitosa";
            }

            return(result);
        }
        /// <summary>
        ///     Funcion que dados los datos de un ticket se crea un nuevo elemento
        ///     y su inicio en el historial
        /// </summary>
        /// <param name="ticketRecord">Objeto con los datos para el historial del ticket</param>
        /// <param name="ticket">objeto con los datos del ticket para su creacion </param>
        /// <returns>TicketRegisterResult con el folio y id del ticket nuevo</returns>
        public TicketRegisterResult CreateNewTicket(TK_HD_TICKETS ticket, TK_DT_RECORDS ticketRecord)
        {
            var result = new TicketRegisterResult();

            using (var db = new dbGoldenTicket())
            {
                db.TK_HD_TICKETS.Add(ticket);
                ticketRecord.TK_HD_TICKETS_ID = ticket.TK_HD_TICKETS_ID;
                ticketRecord.TK_DT_RECORDS_ID = GenerateRecordId(ticketRecord.TK_HD_TICKETS_ID);
                db.TK_DT_RECORDS.Add(ticketRecord);
                db.SaveChanges();

                result.FolioNewTicket = ticket.FOLIO;
                result.IdNewTicket    = ticket.TK_HD_TICKETS_ID;

                result.Success = true;
                result.Message = "op_exitosa";
            }

            return(result);
        }