public async Task <ActionResultResponse> Delete(string tenantId, string newsId) { var info = await _newsRepository.GetInfo(newsId); if (info == null) { return(new ActionResultResponse(-1, _websiteResourceService.GetString("News does not exists. Please try again."))); } if (info.TenantId != tenantId) { return(new ActionResultResponse(-2, _sharedResourceService.GetString(ErrorMessage.NotHavePermission))); } if (info.Status != ApproverStatus.Draft && info.Status != ApproverStatus.Decline) { return(new ActionResultResponse(-1, _websiteResourceService.GetString("News is used. Please try again."))); } var isExistsInMenu = await _menuItemRepository.CheckExistsBySubjectId(newsId, SubjectType.News); if (isExistsInMenu) { return(new ActionResultResponse(-1, _websiteResourceService.GetString("News are being used by menu. You can not delete this news."))); } var result = await _newsRepository.Delete(newsId); await _newsTranslationRepository.Delete(newsId); return(new ActionResultResponse(result, _websiteResourceService.GetString("Delete news successful."))); }
//public async Task<ActionResultResponse> UpdateOrder(string tenantId, int id, int order, int? parentId) //{ // var categoryInfo = await _categoryRepository.GetInfo(tenantId, id); // if(categoryInfo == null) // return new ActionResultResponse(-1, _resourceService.GetString("Category does not exists.")); //} public async Task <ActionResultResponse> Delete(string tenantId, int id) { // Check exists in news. var isExistsInnews = await _categoriesNewsRepository.CheckExistsByCategoryId(id); if (isExistsInnews) { return(new ActionResultResponse(-1, _resourceService.GetString("Category are being used by news. You can not delete this category."))); } // Check exists in menu. var isExistsInMenu = await _menuItemRepository.CheckExistsBySubjectId(id.ToString(), SubjectType.NewsCategory); if (isExistsInMenu) { return(new ActionResultResponse(-1, _resourceService.GetString("Category are being used by menus. You can not delete this category."))); } var result = await _categoryRepository.Delete(tenantId, id); if (result <= 0) { return(new ActionResultResponse(result, result == -1 ? _resourceService.GetString("Category doest not exists.") : _sharedResourceService.GetString("Something went wrong. Please contact with administrator."))); } // Delete category translation. await _categoryTranslationRepository.DeleteByCategoryId(id); return(new ActionResultResponse(result, _resourceService.GetString("Delete category successful."))); }