Exemplo n.º 1
0
        public async Task<bool> Update(OrderState item)
        {
            var state = await IdExist(item.Id);
            state.StatusTh = item.StatusTh;
            state.StatusEn = item.StatusEn;

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

            return true;
        }
Exemplo n.º 2
0
 public async Task<OrderState> Add(OrderState item)
 {
     var state = new OrderState
     {
         StatusEn = item.StatusEn,
         StatusTh = item.StatusTh
     };
     
     state = _db.OrderStates.Add(state);
     try
     {
         await _db.SaveChangesAsync();
         return state;
     }
     catch (DbUpdateConcurrencyException exception)
     {
         throw new DbUpdateConcurrencyException(exception.Message);
     }
 }