Example #1
0
        public void AddResistance(ResistanceCreateDto resistance, ProtestoCreateDto protesto)
        {
            var resistanceQuery = "insert into Resistance(CompanyId, CategoryId, EmployeeCountId, EmployeeCount, HasTradeUnion, TradeUnionAuthorityId, TradeUnionId, StartDate, EndDate)" +
                                  "values(@CompanyId, @CategoryId, @EmployeeCountId, @EmployeeCount, @HasTradeUnion, @TradeUnionAuthorityId, @TradeUnionId, @StartDate, @EndDate);" +
                                  "SELECT LAST_INSERT_ID()";

            var resistanceId = _connection.Query <int>(resistanceQuery, new
            {
                resistance.CompanyId,
                resistance.CategoryId,
                resistance.EmployeeCountId,
                resistance.EmployeeCount,
                resistance.HasTradeUnion,
                resistance.TradeUnionAuthorityId,
                resistance.TradeUnionId,
                resistance.StartDate,
                resistance.EndDate
            }).Single();

            if (resistance.CorporationIds != null)
            {
                foreach (var item in resistance.CorporationIds)
                {
                    var corporationsQuery = "insert into resistancetocorporation(resistanceId, corporationId)" +
                                            "values(@resistanceId, @corporationId)";
                    _connection.Query <int>(corporationsQuery, new
                    {
                        resistanceId,
                        corporationId = item
                    });
                }
            }
            if (resistance.EmploymentTypeIds != null)
            {
                foreach (var item in resistance.EmploymentTypeIds)
                {
                    var corporationsQuery = "insert into resistancetoemploymenttype(resistanceId, employmenttypeId)" +
                                            "values(@resistanceId, @employmenttypeId)";
                    _connection.Query <int>(corporationsQuery, new
                    {
                        resistanceId,
                        employmenttypeId = item
                    });
                }
            }
            var protestoQuery = "insert into Protesto(ResistanceId, EmployeeCountInProtestoId, EmployeeCountInProtesto, CustodyCount, GenderId, IsAgainstProduction, ProtestoStartDate, ProtestoEndDate)" +
                                "values(@ResistanceId, @EmployeeCountInProtestoId, @EmployeeCountInProtesto, @CustodyCount, @GenderId, @IsAgainstProduction, @ProtestoStartDate, @ProtestoEndDate);" +
                                "SELECT LAST_INSERT_ID()";
            var protestoId = _connection.Query <int>(protestoQuery, new
            {
                resistanceId,
                protesto.EmployeeCountInProtestoId,
                protesto.EmployeeCountInProtesto,
                protesto.CustodyCount,
                protesto.GenderId,
                protesto.IsAgainstProduction,
                protesto.ProtestoEndDate,
                protesto.ProtestoStartDate
            }).Single();

            foreach (var item in protesto.ProtestoTypeIds)
            {
                var protestotypeQuery = "insert into Protestototype(protestoId, protestotypeId)" +
                                        "values(@ProtestoId, @protestotypeId)";
                _connection.Query <int>(protestotypeQuery, new
                {
                    protestoId,
                    protestotypeId = item
                });
            }

            foreach (var item in protesto.ProtestoPlaceIds)
            {
                var protestoplaceQuery = "insert into Protestotoplace(protestoId, protestoplaceId)" +
                                         "values(@ProtestoId, @protestoplaceId)";
                _connection.Query <int>(protestoplaceQuery, new
                {
                    protestoId,
                    protestoplaceId = item
                });
            }
            if (protesto.InterventionTypeIds != null)
            {
                foreach (var item in protesto.InterventionTypeIds)
                {
                    var protestoplaceQuery = "insert into Protestotointerventiontype(protestoId, interventiontypeId)" +
                                             "values(@ProtestoId, @interventiontypeId)";
                    _connection.Query <int>(protestoplaceQuery, new
                    {
                        protestoId,
                        interventiontypeId = item
                    });
                }
            }
        }
Example #2
0
 public void AddResistance(ResistanceCreateDto resistance, ProtestoCreateDto protesto, CompanyDto company)
 {
     _connection.Execute("insert into Resistance() values()", new
     {
     });
 }