public ActionResult <int> PostCategory([FromBody] JsonElement request)
        {
            var         req      = request.GetRawText();
            CategoryDto category = JsonConvert.DeserializeObject <CategoryDto>(req);

            return(Created(new Uri(""), _manager.AddCategory(category)));
        }
 public IActionResult Post(Category category)
 {
     try
     {
         Category addedCategory = categoryManager.AddCategory(category);
         return(CreatedAtAction("Post", new { id = addedCategory.Id }));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemple #3
0
        public async Task <HttpResponseMessage> AddCategory(Entities.Entities.Category category)
        {
            Response <Entities.Entities.Category> httpResponse = new  Response <Entities.Entities.Category>();

            try
            {
                httpResponse.RequestState = true;
                httpResponse.ErrorState   = !await _categoryManager.AddCategory(category);
            }
            catch (Exception ex)
            {
                httpResponse.ErrorState = true;
                httpResponse.ErrorList.Add(ex.Adapt <ApiException>());
            }
            return(httpResponse);
        }
        public async Task <ActionResult <Category> > AddCategory([FromBody] Category request)
        {
            try
            {
                var categoryType = new Category
                {
                };

                var result = await _categoryManager.AddCategory(categoryType);

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError("An error has been thrown in CategoryController:AddCategory");
                return(BadRequest(ex));
            }
        }
        public async Task <HttpResponseMessage> AddCategory(AddCategoryDto req)
        {
            _logger.LogDebug("AddCategory init with", req);
            Response <Entities.Entities.Category> httpResponse = new  Response <Entities.Entities.Category>();

            try
            {
                httpResponse.RequestState = true;
                httpResponse.ErrorState   = !await _categoryManager.AddCategory(req);
            }
            catch (Exception ex)
            {
                _logger.LogError("AddCategory Error", ex);
                httpResponse.ErrorState = true;
                httpResponse.ErrorList.Add(ex.Adapt <ApiException>());
            }
            _logger.LogDebug("AddCategory end with", httpResponse);
            return(httpResponse);
        }
Exemple #6
0
 public void AddCategory(CategoryRequest request)
 {
     ValidateRequest(request);
     categoryManager.AddCategory(request);
 }
 public async Task <IActionResult> AddCategory(string categoryName)
 {
     return(Ok(await _categoryManager.AddCategory(categoryName)));
 }
Exemple #8
0
 public void TestAddCategory()
 {
     categoryManager.AddCategory(request);
 }
Exemple #9
0
 public JsonResult AddCategory(AddCategoryModel model)
 {
     ViewBag.SelectedTab = SelectedAdminTab.Category;
     return(JsonResult(_CategoryManager.AddCategory(model)));
 }
Exemple #10
0
 public long AddCategory(CategoryDto category)
 {
     return(ExecuteWithExceptionHandling(() => _categoryManager.AddCategory(category)));
 }