Пример #1
0
        public async Task <IHttpActionResult> Post(TransactionType item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            item.ObjectState = ObjectState.Added;
            _service.Insert(item);

            try
            {
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ItemExists(item.TransactionTypeID))
                {
                    return(Conflict());
                }
                throw;
            }

            return(Created(item));
        }
        public async Task <ActionResult <TransactionTypeModel> > PostTransactionType(TransactionTypeModel transactionType)
        {
            try
            {
                var savedModel = await _transactionTypeService.Insert(transactionType);

                return(Ok(savedModel));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }