Exemple #1
0
        private async Task <int> AddSerials(List <SerialsDB> serials, int id)
        {
            int adds     = 0;
            int idSerial = _arrivalsService.GetLastIdArrivalSerials().Result;

            idSerial++;
            foreach (var s in serials)
            {
                var existingSerial = _serialService.GetSerialBySerial(s.Serial);
                var aux            = existingSerial.Result != null ? existingSerial.Result.Id : 0;
                if (aux != 0)
                {
                    var newItem = new ArrivalSerials
                    {
                        Id        = idSerial,
                        Serial    = s.Serial.ToString(),
                        ArrivalID = id
                    };
                    idSerial++;

                    var res = await _arrivalsService.UpdateArrivalSerialsTable(newItem);

                    adds += res;
                }
            }
            return(adds);
        }
        public async Task <int> UpdateArrivalSerialsTable(ArrivalSerials item)
        {
            DbConnection connection = GetConnection();

            string insertQuery = @"INSERT INTO [dbo].[ArrivalSerials]([Id], [Serial], [ArrivalID]) VALUES (" +
                                 item.Id + ", '" + item.Serial + "', " + item.ArrivalID + ")";

            var result = connection.Execute(insertQuery);

            connection.Close();
            return(result);
        }