Ejemplo n.º 1
0
        public async Task<bool> Update(SimNetwork item)
        {
            var brand = await IdExist(item.Id);

            if (await NameExist(item.BrandName)) return false;

            brand.BrandName = item.BrandName;

            _db.Entry(brand).State = EntityState.Modified;
            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException exception)
            {
                throw new DbUpdateConcurrencyException(exception.Message);
            }

            return true;
        }
Ejemplo n.º 2
0
        public async Task<SimNetwork> Add(SimNetwork item)
        {
            if (await NameExist(item.BrandName)) return null;

            var newBrand = new SimNetwork
            {
                BrandName = item.BrandName
            };

            newBrand = _db.SimNetworks.Add(newBrand);
            try
            {
                await _db.SaveChangesAsync();
                return newBrand;
            }
            catch (DbUpdateConcurrencyException exception)
            {
                throw new DbUpdateConcurrencyException(exception.Message);
            }
        }