Esempio n. 1
0
        public async Task ListDepartment()
        {
            //Arrange

            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);

            var fakedepartment = new Departamento()
            {
                Nombre = "Lima",
            };

            var fakedepartment2 = new Departamento()
            {
                Nombre = "Ancash",
            };



            context.Departamento.Add(fakedepartment);
            context.Departamento.Add(fakedepartment2);
            await context.SaveChangesAsync();

            var context2 = BuildContext(BDName);

            //Act
            var controller = new DepartamentosController(context2);

            var response = await controller.List();


            //Assert
            Assert.IsNotNull(response);
        }
Esempio n. 2
0
        public static Result guardar(int id, int usuarioId, string nombre, string codigoDane)
        {
            Result r = ValidateSession.validarSession(usuarioId, HttpContext.Current.Session["usuarioId"]);

            if (r.error != "")
            {
                return(r);
            }
            Departamentos objEntity = new Departamentos();

            objEntity.id         = id;
            objEntity.usuarioId  = usuarioId;
            objEntity.nombre     = nombre;
            objEntity.codigoDane = codigoDane;
            try
            {
                return(DepartamentosController.guardarDepartamentos(objEntity));
            }
            catch (Exception ex)
            {
                return(new Result()
                {
                    error = ex.Message, id = 0, tipoAlerta = "warning"
                });
            }
        }
Esempio n. 3
0
        public static Result getListaDepartamentos(int registroPartida, int totalAExtraer, int usuarioId)
        {
            Result r = ValidateSession.validarSession(usuarioId, HttpContext.Current.Session["usuarioId"]);

            if (r.error != "")
            {
                return(r);
            }
            int totalRegistros = 0;
            List <DepartamentosViewModel> lst = new List <DepartamentosViewModel>();

            try
            {
                lst            = DepartamentosController.getListaDepartamentos();
                totalRegistros = lst.Count();
                totalAExtraer  = (lst.Count() - registroPartida) < totalAExtraer ? (lst.Count() - registroPartida) : totalAExtraer;
            }
            catch (Exception e)
            {
                return(new Result()
                {
                    error = e.Message, id = 0, tipoAlerta = "warning"
                });
            }
            return(new Result()
            {
                error = "", getCadena = new JavaScriptSerializer().Serialize(lst.GetRange(registroPartida, totalAExtraer)), totalRegistros = totalRegistros
            });
        }
Esempio n. 4
0
        public static Result eliminar(int id, int usuarioId)
        {
            Result r = ValidateSession.validarSession(usuarioId, HttpContext.Current.Session["usuarioId"]);

            if (r.error != "")
            {
                return(r);
            }

            try
            {
                return(DepartamentosController.eliminarDepartamentos(id, usuarioId));
            }
            catch (Exception ex)
            {
                return(new Result()
                {
                    error = ex.Message, id = 0, tipoAlerta = "warning"
                });
            }
        }
Esempio n. 5
0
        public async Task AddaDepartment()
        {
            //Arrange


            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);


            //Act

            var newdepartment = new CreateDepartamentoViewModel()
            {
                Nombre = "Lima",
            };

            var controller = new DepartamentosController(context);

            var response = await controller.Create(newdepartment);

            //Assert

            Assert.IsNotNull(response);
        }