Beispiel #1
0
        public async Task <ResultOperation> EliminarAsync(PersonaDto dto)
        {
            var result = new ResultOperation();
            var entity = await _uow.Personas.FindAsync(dto.Id);

            _uow.Personas.Remove(entity);
            await _uow.SaveChangesAsync();

            return(result);
        }
Beispiel #2
0
        public static async Task AddTestData(AppUnitOfWork context)
        {
            if (context.Personas.Any())
            {
                return;
            }

            var testData = new List <Persona>()
            {
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Santa Cruz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = (new Random().Next(1000, 15000)) + 0.55123m,
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Santa Cruz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = (new Random().Next(1000, 15000)) + 0.55123m,
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Santa Cruz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = (new Random().Next(1000, 15000)) + 0.55123m,
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Santa Cruz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = (new Random().Next(1000, 15000)) + 0.55123m,
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Cochabamba",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Cochabamba",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Cochabamba",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Cochabamba",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "La Paz",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Oruro",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Oruro",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Oruro",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Oruro",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
                new Persona
                {
                    Nombres     = Guid.NewGuid().ToString().Substring(0, 8),
                    Apellidos   = Guid.NewGuid().ToString().Substring(0, 10),
                    Cargo       = Position.Accountant,
                    Oficina     = "Oruro",
                    Experiencia = short.Parse(new Random().Next(1, 20).ToString()),
                    FechaInicio = new DateTime(new Random().Next(1900, 2020), 01, 01),
                    Salario     = new Random().Next(1000, 15000),
                },
            };

            context.Personas.AddRange(testData);
            await context.SaveChangesAsync();
        }