Ejemplo n.º 1
0
        public ActionResult SimpleSearchServicioBasico(SimpleListViewModel parameters)
        {
            var transfer      = new ClientTransfer();
            var anyoQueriable = _haberesService.GetServiciosBasicos();

            if (!string.IsNullOrEmpty(parameters.Descripcion))
            {
                anyoQueriable = anyoQueriable.Where(a => a.Nombre.Contains(parameters.Descripcion));
            }

            var selectQuery = anyoQueriable.Select(a => new
            {
                a.Id,
                Descripcion = a.Nombre
            }).OrderBy(o => o.Descripcion);

            var listado = selectQuery
                          .Skip((parameters.PageIndex - 1) * parameters.ItemsPerPage)
                          .Take(parameters.ItemsPerPage)
                          .ToList();

            var totalElements = selectQuery.Count();
            var totalpages    = totalElements / parameters.ItemsPerPage;

            transfer.Data = listado;
            transfer.Pagination.TotalPages          = totalpages + ((totalElements % parameters.ItemsPerPage) > 0 ? 1 : 0);
            transfer.Pagination.TotalRecords        = totalElements; //Total de elementos segun filtro
            transfer.Pagination.TotalDisplayRecords = listado.Count; //Total de elementos segun pagina
            return(Json(transfer));
        }
        public ActionResult Create(SimpleListViewModel simpleListViewModel)
        {
            var service = new ApiService();

            service.CreateSimpleList(simpleListViewModel);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public void SimpleListToSimpleListViewModelTest()
        {
            Mapper target = new Mapper();                                           // TODO: Initialize to an appropriate value

            Infostructure.SimpleList.DataModel.Models.SimpleList simpleList = null; // TODO: Initialize to an appropriate value
            bool populateSubStructures   = false;                                   // TODO: Initialize to an appropriate value
            SimpleListViewModel expected = null;                                    // TODO: Initialize to an appropriate value
            SimpleListViewModel actual;

            actual = target.SimpleListToSimpleListViewModel(simpleList, populateSubStructures);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 4
0
 public DataModel.Models.SimpleList SimpleListViewModelToSimpleList(SimpleListViewModel simpleListViewModel)
 {
     DataModel.Models.SimpleList simpleList = new DataModel.Models.SimpleList();
     simpleList.ID        = simpleListViewModel.ID;
     simpleList.Name      = simpleListViewModel.Name;
     simpleList.AllDone   = simpleListViewModel.AllDone;
     simpleList.DateAdded = simpleListViewModel.DateAdded;
     // We only populate the UserID if we have a value to populate.
     if (simpleListViewModel.UserID.HasValue)
     {
         simpleList.UserID = simpleListViewModel.UserID.Value;
     }
     return(simpleList);
 }
Ejemplo n.º 5
0
        public SimpleListViewModel SimpleListToSimpleListViewModel(DataModel.Models.SimpleList simpleList, bool populateSubStructures = true)
        {
            SimpleListViewModel simpleListViewModel = new SimpleListViewModel();

            simpleListViewModel.ID        = simpleList.ID;
            simpleListViewModel.Name      = simpleList.Name;
            simpleListViewModel.UserID    = simpleList.UserID;
            simpleListViewModel.AllDone   = simpleList.AllDone;
            simpleListViewModel.DateAdded = simpleList.DateAdded;
            // We only populate the SimpleListItems if specifically requested.
            if (populateSubStructures)
            {
                simpleListViewModel.SimpleListItems = SimpleListItemsToSimpleListItemViewModels(simpleList.SimpleListItems.AsEnumerable <DataModel.Models.SimpleListItem>());
            }
            return(simpleListViewModel);
        }
Ejemplo n.º 6
0
        public int CreateSimpleList(SimpleListViewModel simpleListViewModel)
        {
            // Authenticate.
            var user = GetUserCredentials();

            if (user == null)
            {
                return(0);
            }

            var mapper     = new Mapper();
            var simpleList = mapper.SimpleListViewModelToSimpleList(simpleListViewModel);

            simpleList.UserID     = user.ID;
            simpleList.DateAdded  = DateTime.Now;
            _simpleListRepository = new SimpleListRepository();
            return(_simpleListRepository.AddSimpleList(simpleList));
        }
Ejemplo n.º 7
0
        public void SimpleListToSimpleListViewModelTest()
        {
            Mapper target = new Mapper();

            DataModel.Models.SimpleList simpleList = new DataModel.Models.SimpleList
            {
                ID              = 1,
                DateAdded       = DateTime.Now,
                AllDone         = false,
                UserID          = 1,
                Name            = "test list 1",
                SimpleListItems = new List <DataModel.Models.SimpleListItem>
                {
                    new DataModel.Models.SimpleListItem {
                        ID = 1, Description = "test list item 1", Done = false, SimpleListID = 1
                    },
                    new DataModel.Models.SimpleListItem {
                        ID = 2, Description = "test list item 2", Done = true, SimpleListID = 1
                    }
                }
            };
            SimpleListViewModel expected = new SimpleListViewModel
            {
                ID              = 1,
                DateAdded       = DateTime.Now,
                AllDone         = false,
                UserID          = 1,
                Name            = "test list 1",
                SimpleListItems = new List <Models.SimpleListItemViewModel>
                {
                    new Models.SimpleListItemViewModel {
                        ID = 1, Description = "test list item 1", Done = false, SimpleListID = 1
                    },
                    new Models.SimpleListItemViewModel {
                        ID = 2, Description = "test list item 2", Done = true, SimpleListID = 1
                    }
                }
            };
            SimpleListViewModel actual;

            actual = target.SimpleListToSimpleListViewModel(simpleList);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public ActionResult SimpleSearchEmpresas(SimpleListViewModel parameters)
        {
            var transfer = new ClientTransfer();

            var anyoQueriable = _pedidosService.BuscarEmpresas();

            anyoQueriable = anyoQueriable.Where(a => a.Activa);
            var empresas     = Session["Empresas"].ToString();
            var listEmpresas = empresas.Contains(",")
                ? empresas.Split(',').Select(a => int.Parse(a)).ToList()
                : new List <int>()
            {
                int.Parse(empresas)
            };

            anyoQueriable = anyoQueriable.Where(a => listEmpresas.Contains(a.Id));

            //if (!string.IsNullOrEmpty(parameters.Descripcion))
            //    anyoQueriable = anyoQueriable.Where(a => a.Nombre.Contains(parameters.Descripcion));

            var selectQuery = anyoQueriable.Select(a => new
            {
                a.Id,
                Descripcion = a.Nombre.Trim()
            }).OrderBy(o => o.Descripcion);

            var listado = selectQuery
                          .Skip((parameters.PageIndex - 1) * parameters.ItemsPerPage)
                          .Take(parameters.ItemsPerPage)
                          .ToList();

            var totalElements = selectQuery.Count();
            var totalpages    = totalElements / parameters.ItemsPerPage;

            transfer.Data = listado;
            transfer.Pagination.TotalPages          = totalpages + ((totalElements % parameters.ItemsPerPage) > 0 ? 1 : 0);
            transfer.Pagination.TotalRecords        = totalElements; //Total de elementos segun filtro
            transfer.Pagination.TotalDisplayRecords = listado.Count; //Total de elementos segun pagina
            return(Json(transfer));
        }
Ejemplo n.º 9
0
        public ActionResult SimpleSearchCliente(SimpleListViewModel parameters)
        {
            var transfer      = new ClientTransfer();
            var anyoQueriable = _clientesService.Buscar();

            anyoQueriable = anyoQueriable.Where(a => a.Activo);

            if (!string.IsNullOrEmpty(parameters.Descripcion))
            {
                anyoQueriable = anyoQueriable.Where(a => a.Nombres.Contains(parameters.Descripcion));
            }

            if (parameters.IdEmpresa.HasValue)
            {
                anyoQueriable = anyoQueriable.Where(a => a.EmpresaId == parameters.IdEmpresa);
            }

            var selectQuery = anyoQueriable.Select(a => new
            {
                a.Id,
                Descripcion = (a.Nombres + " " + a.Apellidos).Trim()
            }).OrderBy(o => o.Descripcion);

            var listado = selectQuery
                          .Skip((parameters.PageIndex - 1) * parameters.ItemsPerPage)
                          .Take(parameters.ItemsPerPage)
                          .ToList();

            var totalElements = selectQuery.Count();
            var totalpages    = totalElements / parameters.ItemsPerPage;

            transfer.Data = listado;
            transfer.Pagination.TotalPages          = totalpages + ((totalElements % parameters.ItemsPerPage) > 0 ? 1 : 0);
            transfer.Pagination.TotalRecords        = totalElements; //Total de elementos segun filtro
            transfer.Pagination.TotalDisplayRecords = listado.Count; //Total de elementos segun pagina
            return(Json(transfer));
        }