Пример #1
0
        public async Task <IHttpActionResult> Post(ItemCategoryModel ic)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var mapped = _mapper.Map <ItemCategory>(ic);
                    _repo.AddItemCategory(mapped);

                    if (await _repo.SaveChangesAsync())
                    {
                        return(Created("GetItemCategories", mapped.ItemCategoryId));
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(BadRequest());
        }