예제 #1
0
        public List <SelectListItem> GetListOfPriorities()
        {
            _database = new dbSIACEntities();
            List <PriorityViewModel> listOfPriorities = null;

            using (_database)
            {
                listOfPriorities = (from priority in _database.priority
                                    select new PriorityViewModel
                {
                    keyPriority = priority.id,
                    valuePriority = priority.name
                }
                                    ).ToList();
            }

            var prioritiesList = listOfPriorities.ConvertAll(data => new SelectListItem
            {
                Text     = data.valuePriority,
                Value    = data.keyPriority.ToString(),
                Selected = false
            });

            _database.Dispose();
            return(prioritiesList);
        }
예제 #2
0
        public List <SelectListItem> GetListOfRols()
        {
            _database = new dbSIACEntities();
            List <RolsViewModel> listOfRols = null;

            using (_database)
            {
                listOfRols = (from rol in _database.rol
                              select new RolsViewModel
                {
                    keyRols = rol.id,
                    valueRols = rol.name
                }
                              ).ToList();
            }

            var rolList = listOfRols.ConvertAll(data => new SelectListItem
            {
                Text     = data.valueRols,
                Value    = data.keyRols.ToString(),
                Selected = false
            });

            _database.Dispose();
            return(rolList);
        }
예제 #3
0
        public List <SelectListItem> GetListOfStatus()
        {
            _database = new dbSIACEntities();
            List <StatusViewModel> listOfStatus = null;

            using (_database)
            {
                listOfStatus = (from status in _database.status
                                select new StatusViewModel
                {
                    keyStatus = status.id,
                    valueStatus = status.name
                }
                                ).ToList();
            }

            var statusList = listOfStatus.ConvertAll(data => new SelectListItem
            {
                Text     = data.valueStatus,
                Value    = data.keyStatus.ToString(),
                Selected = false
            });

            _database.Dispose();
            return(statusList);
        }
        public bool EditTicket(TicketViewModel baseTicket, string ticketId)
        {
            if (!int.TryParse(ticketId, out var currentTicketId))
            {
                return(false);
            }

            _database = new dbSIACEntities();
            using (_database)
            {
                var result = _database.ticket.FirstOrDefault(b => b.idLocal == currentTicketId);
                if (result == null)
                {
                    _database.Dispose();
                    return(false);
                }

                result.idCategory           = baseTicket.idCategory;
                result.idAssignedTechnician = baseTicket.idAssignedTechnician;
                result.idPriority           = baseTicket.idPriority;
                result.idStatus             = baseTicket.idStatus;
                result.description          = baseTicket.description;
                _database.SaveChanges();
            }

            return(true);
        }
        public TicketViewModel GeTicketViewModel(int ticketIdLocal)
        {
            _database = new dbSIACEntities();
            var ticketViewModel = new TicketViewModel();

            using (_database)
            {
                var ticket = _database.ticket.FirstOrDefault(currentTicket => currentTicket.idLocal == ticketIdLocal);
                if (ticket == null)
                {
                    return(null);
                }
                if (ticket.idClient != null)
                {
                    ticketViewModel.idClient = (int)ticket.idClient;
                }
                ticketViewModel.idAssignedTechnician = ticket.idAssignedTechnician;
                ticketViewModel.creationDate         = ticket.creationDate;
                ticketViewModel.estimatedFinishDate  = ticket.estimatedFinishDate;
                ticketViewModel.idPriority           = ticket.idPriority;
                ticketViewModel.idCategory           = ticket.idCategory;
                ticketViewModel.idStatus             = ticket.idStatus;
                ticketViewModel.creationDate         = ticket.creationDate;
                ticketViewModel.description          = ticket.description;
            }

            _database.Dispose();
            return(ticketViewModel);
        }
예제 #6
0
        public List <TechniciansViewModel> GetListTechnicians()
        {
            _database = new dbSIACEntities();
            var technicianIdRol = 2;

            List <TechniciansViewModel> listOfTechnicians = null;

            using (_database)
            {
                listOfTechnicians = (from technicians in _database.people
                                     where technicians.idRol == technicianIdRol
                                     select new TechniciansViewModel
                {
                    keyTechnician = technicians.id,
                    nameTechnician = technicians.name
                }
                                     ).ToList();
            }

            _database.Dispose();
            return(listOfTechnicians);
        }
예제 #7
0
        public List <AdminsViewModel> GetListAdmins()
        {
            _database = new dbSIACEntities();
            var AdminIdRol = 1;

            List <AdminsViewModel> listOfAdmins = null;

            using (_database)
            {
                listOfAdmins = (from admins in _database.people
                                where admins.idRol == AdminIdRol
                                select new AdminsViewModel
                {
                    keyAdmin = admins.id,
                    emailAdmin = admins.email
                }
                                ).ToList();
            }

            _database.Dispose();
            return(listOfAdmins);
        }
예제 #8
0
        public List <SelectListItem> GetListOfCategories()
        {
            _database = new dbSIACEntities();
            List <CategoriesViewModel> listOfCategories = null;

            listOfCategories = (from cat in _database.category
                                select new CategoriesViewModel
            {
                keyCategories = cat.id,
                nameCategories = cat.name
            }
                                ).ToList();

            var categoriesList = listOfCategories.ConvertAll(data => new SelectListItem
            {
                Text     = data.nameCategories,
                Value    = data.keyCategories.ToString(),
                Selected = false
            });

            _database.Dispose();
            return(categoriesList);
        }
예제 #9
0
        public List <PeopleViewModel> GetListClients()
        {
            _database = new dbSIACEntities();
            var clientsIdRol = 3;

            List <PeopleViewModel> listOfClients = null;

            using (_database)
            {
                listOfClients = (from people in _database.people
                                 where people.idRol == clientsIdRol
                                 select new PeopleViewModel
                {
                    keyClient = people.id,
                    nameClient = people.name,
                    addressClient = people.address,
                    lastNameClient = people.lastname
                }
                                 ).ToList();
            }

            _database.Dispose();
            return(listOfClients);
        }