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

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

            payment.PaymentName = item.PaymentName;

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

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

            var newPayment = new SimFeeType()
            {
                PaymentName = item.PaymentName
            };

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