コード例 #1
0
        public async Task <Unit> Handle(CreateEmployeeCommand request, CancellationToken cancellationToken)
        {
            var employee = new employee();

            employee.id   = int.Parse(tools.generateId());
            employee.curp = request.curp;
            //int days = DataCalc.daysLived(request.fecha_nacimiento);
            //employee.dias_vividos = days;
            employee.fecha_nacimiento = request.fecha_nacimiento;

            using (var dbContextTransaction = _ctx.Database.BeginTransaction())
            {
                _ctx.employees.Add(employee);
                await _ctx.SaveChangesAsync();

                dbContextTransaction.Commit();
            }

            return(Unit.Value);
        }
コード例 #2
0
        public async Task <Unit> Handle(RegisterAccidentCommand request, CancellationToken cancellationToken)
        {
            var accident = new accident();

            accident.id                  = int.Parse(tools.generateId());
            accident.curp                = request.curp;
            accident.fecha_accidente     = request.fecha_accidente;
            accident.residuo_fisico      = request.residuo_fisico;
            accident.residuo_emocional   = request.residuo_emocional;
            accident.residuo_intelectual = request.residuo_intelectual;
            accident.residuo_intuicional = request.residuo_intuicional;

            using (var dbContextTransaction = _ctx.Database.BeginTransaction())
            {
                _ctx.accidents.Add(accident);
                await _ctx.SaveChangesAsync();

                dbContextTransaction.Commit();
            }

            return(Unit.Value);
        }