Пример #1
0
        public List<Ticket> GetAll()
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            List<tbl_Tickets> dbListTickets = context.tbl_Tickets.ToList();

            List<Ticket> entList = new List<Ticket>();

            foreach (var drItem in dbListTickets)
            {
                Ticket entItem = new Ticket();
                AssignDataObjectToEntity(drItem, ref entItem);
                entList.Add(entItem);
            }

            return entList;
        }
Пример #2
0
 public int Save(Ticket newTicket)
 {
     int blResult = -1;
     try
     {
         if (newTicket.IdTicket == 0)
         {
             blResult = Insert(newTicket);
         }
         else
         {
             blResult = Update(newTicket);
         }
     }
     catch {
         return -1;
     }
     return blResult;
 }
Пример #3
0
        private void AssignDataObjectToEntity(tbl_Tickets dbCategory, ref Ticket entity)
        {
            entity.IdTicket = dbCategory.IdTicket;
            entity.Description = dbCategory.Description;
            entity.CreatedOn = dbCategory.CreatedOn;
            entity.AssignedTo = new Security.MembershipService().GetUserById(dbCategory.IdAssignedTo);
            entity.Category = new CategoryService().GetByID(dbCategory.IdCategory);
            entity.TicketStatus = dbCategory.TicketStatus == "Abierto" ? Ticket.TicketStatusEnum.Abierto : Ticket.TicketStatusEnum.Cerrado;
            entity.CreatedBy = new Security.MembershipService().GetUserById(dbCategory.CreatedBy);
            entity.CloseDescription = dbCategory.CloseDescription;
            try
            {
                entity.ClosedOn = dbCategory.ClosedOn;
                entity.ClosedOnByUser = dbCategory.ClosedOnByUser.Value;
            }
            catch
            { }

            entity.IdPrioriy = dbCategory.IdPriority;
        }
Пример #4
0
 public List<Ticket> GetAllByIdCompanyStatus(int ID,Ticket.TicketStatusEnum Status)
 {
     List<Ticket> entityList = GetAll().Where(t => t.CreatedBy.EntCompany.IdCompany == ID && t.TicketStatus == Ticket.TicketStatusEnum.Abierto).ToList();
     return entityList;
 }
Пример #5
0
        private int Update(Ticket entTicket)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            try {
                tbl_Tickets dbTickets = context.tbl_Tickets.Where(t => t.IdTicket == entTicket.IdTicket).FirstOrDefault();
                dbTickets.CloseDescription = entTicket.CloseDescription;
                dbTickets.ClosedOn = DateTime.Now;
                dbTickets.TicketStatus = entTicket.TicketStatus.ToString();
                dbTickets.ClosedOnByUser = entTicket.ClosedOnByUser;

                context.SubmitChanges();
                return dbTickets.IdTicket;
            }
            catch { }
            return -1;
        }
Пример #6
0
        private int Insert(Ticket entTicket)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            try
            {
                tbl_Tickets dbTickets = new tbl_Tickets() {
                    CloseDescription = entTicket.CloseDescription,
                    CreatedOn = entTicket.CreatedOn,
                    CreatedBy = entTicket.CreatedBy.IdUser,
                    Description = entTicket.Description,
                    IdAssignedTo = entTicket.AssignedTo.IdUser,
                    IdCategory = entTicket.Category.IdCategory,
                    IdPriority = entTicket.IdPrioriy,
                    TicketStatus = entTicket.TicketStatus.ToString()
                };
                context.tbl_Tickets.InsertOnSubmit(dbTickets);
                context.SubmitChanges();

                return dbTickets.IdTicket;
            }
            catch
            { }
            return -1;
        }