Esempio n. 1
0
        public async Task <SerialsDB> Add(string newSerial)
        {
            var existingSerial = _serialService.GetSerialBySerial(newSerial);

            if (existingSerial.Id != 0)
            {
                int id = _serialService.GetLastIdSerial().Result;

                var serial = new SerialsDB
                {
                    Id     = id + 1,
                    Serial = newSerial
                };

                var result = await _context.Serials.AddAsync(serial);

                return(result.Entity);
            }

            return(new SerialsDB {
            });
        }