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

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

            status.Name = item.Name;

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

            return true;
        }
Exemplo n.º 2
0
        public async Task<LogStatus> Add(LogStatus item)
        {
            if (await NameExist(item.Name)) return null;

            var newstatus = new LogStatus
            {
                Name = item.Name
            };

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