//To Add new Category record public void AddCategory(CategoryModel Category) { try { ICategoryrepo.AddCategory(Category); } catch (Exception ex) { Console.WriteLine(ex); } }
public ActionResult Create([Bind(Include = "Title")] Category category) { if (ModelState.IsValid) { _repo.AddCategory(category); _repo.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <Category> Handle(CreateCategoryCommand request, CancellationToken cancellationToken) { Category exists = _categoryRepo.GetCategoryByName(request.category.Name); if (exists != null) { return(await Task.Run(() => { return new Category(); })); } else { return(await _categoryRepo.AddCategory(request.category)); } }
public void AddCategory(Category category) { if (category == null) { throw new ServiceNullArgumentException("Category was null"); } try { categoryRepo.AddCategory(category); } catch (DALException ex) { throw new ServiceException($"DAL exception : {ex.Message}"); } }
public IActionResult AddCategory([FromBody] AddCategoryModel addCategoryModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Category newCategory = new Category() { Title = addCategoryModel.Title }; var response = _categoryRepo.AddCategory(newCategory); return(Ok(response)); }
public void AddCategory(Category category) { repo.AddCategory(category); }