Exemplo n.º 1
0
        public async Task<bool> Update(LpType item)
        {
            var type =await IdExist(item.Id);

            type.Name = item.Name;
            type.Meaning = item.Meaning;

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

            return true;
        }
Exemplo n.º 2
0
        public async Task<LpType> Add(LpType item)
        {
            var newType = new LpType
            {
                Name = item.Name,
                Meaning = item.Meaning
            };

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