public async Task Create(string name, CategoryValue categoryValue)
        {
            var subcategory = Subcategory.Create(name, categoryValue);

            subcategoryRepository.AddSubcategory(subcategory);
            await unitOfWork.CompleteAsync();
        }
        public IActionResult AddSubcategory(AddSubcategoryViewModel vm)
        {
            vm.ModifiedBy = User.Identity.Name;
            _subcategoryRepo.AddSubcategory(vm);
            var url = Url.Action("Index", "Subcategory");

            return(Json(url));
        }
Exemple #3
0
        public HttpResponseMessage AddSubcategory(int CatId, Subcategory newSubcategory)
        {
            if (string.IsNullOrWhiteSpace(newSubcategory.Title))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid subcategory name."));
            }

            _subcategoryRepository.AddSubcategory(CatId, newSubcategory);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Exemple #4
0
        public IActionResult AddSubcategory(string name, long categoryId)
        {
            if (string.IsNullOrEmpty(name) || categoryId == 0)
            {
                return(BadRequest());
            }
            Subcategory subcategory = new Subcategory {
                Name = name, CategoryID = categoryId
            };

            subcategoryRepository.AddSubcategory(subcategory);
            return(Ok(new { subcategory.Id, subcategory.Name }));
        }