//To Delete the record on a particular Category
 public void DeleteCategory(int?id)
 {
     try
     {
         ICategoryrepo.DeleteCategory(id);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Beispiel #2
0
 public ActionResult <string> Delete(int id)
 {
     if (id != 0)
     {
         if (_repository.DeleteCategory(id))
         {
             return(Ok("Deleted"));
         }
     }
     return(BadRequest());
 }
Beispiel #3
0
        public ActionResult Delete(int id)
        {
            var categoryModelFromRepo = _repository.GetCategoryById(id);

            if (categoryModelFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeleteCategory(categoryModelFromRepo);
            _repository.SaveChanges();
            return(NoContent());
        }
Beispiel #4
0
        public ActionResult DeleteCategory(int id)
        {
            var category = _repo.GetCategoryById(id);

            if (category == null)
            {
                return(NotFound());
            }

            _repo.DeleteCategory(category);
            _repo.SaveChanges();

            return(NoContent());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            _repo.DeleteCategory(id);
            try
            {
                _repo.SaveChanges();
            }
            catch
            {
                return(RedirectToAction("Delete"));
            }

            return(RedirectToAction("Index"));
        }
        public IActionResult Delete(int id)
        {
            var category = _categoryRepo.GetCategoryById(id);

            if (category == null)
            {
                return(NotFound());
            }

            _categoryRepo.DeleteCategory(category);

            _categoryRepo.SaveChanges();


            return(RedirectToAction(nameof(Index)));
        }
Beispiel #7
0
        public IActionResult DeleteCategory(int id)
        {
            if (!_repo.CategoryExists(id))
            {
                return(NotFound(new { message = ModelStateToString.ConvertModelStateToString(ModelState) }));
            }

            var categoryObj = _repo.GetCategory(id);

            if (!_repo.DeleteCategory(categoryObj))
            {
                //ModelState.AddModelError("", $"Error occurred during deleting object : {categoryObj.Title}");
                return(StatusCode(500, new { message = $"Error occurred during deleting object : {categoryObj.Title}" }));
            }

            return(NoContent());
        }
Beispiel #8
0
        public Error DeleteCategory(int catId)
        {
            var category = GetCategory(catId);

            if (category == null)
            {
                return(new Error("栏目不存在!"));
            }
            if (category.Childs.Count() != 0)
            {
                return(new Error("栏目包含子栏目!"));
            }
            if (_categoryRep.GetArchiveCount(GetAggregaterootId(), category.Get().Path) != 0)
            {
                return(new Error("栏目包含文档!"));
            }
            foreach (var bind in category.GetTemplates())
            {
                _tempRep.RemoveBind(category.GetDomainId(), bind.BindType);
            }
            _categoryRep.DeleteCategory(GetAggregaterootId(), catId);
            ClearSelf();
            return(null);
        }
Beispiel #9
0
        public async Task <IActionResult> PostDelete([FromRoute] ulong server, [FromRoute] uint id, [FromForm] bool confirm, [FromForm] uint categoryId)
        {
            var authEntry = (AuthEntry)HttpContext.Items["key"];

            if (authEntry is null)
            {
                return(Redirect("/login"));
            }
            if (!confirm || id != categoryId)
            {
                return(BadRequest());
            }
            var userGuilds = await userService.GetAllowedUserGuilds(authEntry);

            var category = await categoryRepo.GetCategory(id);

            if (category is null || !userGuilds.Any(x => x.Id == server) || category.OwnerId != server)
            {
                return(Unauthorized());
            }
            await categoryRepo.DeleteCategory(id);

            return(RedirectToAction("Index", new { server = server }));
        }
Beispiel #10
0
        public ActionResult Delete(int CategoryId)
        {
            ResponseMessage = _categoryRepo.DeleteCategory(CategoryId);

            return(RedirectToAction("Index"));
        }
Beispiel #11
0
 public void DeleteCategory(Category category)
 {
     repo.DeleteCategory(category);
 }