public void GetAllCategoriesTest() { SetMethod(); var test = new CategoryRepository(); test.GetAllCategories(); Assert.AreEqual(1,1); }
public SearchController(CategoryRepository categoryRepository, SearchRepository searchRepository, UserRepository userRepository) { _categoryRepository = categoryRepository; _searchRepository = searchRepository; _userRepository = userRepository; }
public CategoryListViewModel() { //One-liner null checking: if _categoryRepository not null -> use that. If null: creates new instance. _categoryRepository = _categoryRepository ?? new CategoryRepository(); var categoryList = _categoryRepository.GetAllList().Select(c => new CategoryViewModel(c)); Categories = new ObservableCollection<CategoryViewModel>(categoryList); }
public ActionResult Create(FormCollection formCollection) { string title = formCollection.Get("Title"); string body = formCollection.Get("Body"); bool isPublic = formCollection.Get("IsPublic").Contains("true"); IRepository<Category> categoriesRepo = new CategoryRepository(); IRepository<Post> postsRepo = new PostRepository(); List<Category> allCategories = (List<Category>)categoriesRepo.GetAll(); Post post = new Post(); post.Body = body; post.Title = title; post.CreationDate = DateTime.Now; post.IsPublic = isPublic; foreach (Category category in allCategories) { if (formCollection.Get(category.Id.ToString()).Contains("true")) post.Categories.Add(category); } postsRepo.Save(post); return RedirectToAction("Index"); }
private ICategoryService GetCategoryService(UnitOfWork uow) { ICategoryRepository cateRepo = new CategoryRepository(uow); IState request = new DummyRequest(); ILogger logger = new ConsoleLogger(); IUserRepository userRepo = new UserRepository(uow); User user = userRepo.Create(new User { Name = "D. Ummy", ProviderId = "12345678", FullName = "Mr. Doh Ummy", EmailAddress = "[email protected]", Culture = "th-TH", TimeZone = "GMT Standard Time" }); List<IEventSubscriber> subscribers = new List<IEventSubscriber>(); IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request); IUserProvider userProvider = new DummyUserProvider(user); IPermissionService permService = new PermissionService(); return new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService); }
public void CategoryRepository_Update_1() { CategoryRepository categoryRepository = new CategoryRepository(); Category category = categoryRepository.GetByIDs(1); category = new Category() { CategoryID=1, Name="Cake" }; Assert.AreEqual(1, categoryRepository.Update(category)); }
public CategoryDboTest() { productRepository = new ProductRepository(DbContextFactory); repository = new CategoryRepository(DbContextFactory); dataService = new CategoryDataService(repository, UnitOfWork); }
public void CategoryRepository_Update() { var dbHelper = new DbHelper(new SQLitePlatformWinRT(), new TestDatabasePath()); using (var db = dbHelper.GetSqlConnection()) { db.DeleteAll<Category>(); } var repository = new CategoryRepository(new CategoryDataAccess(dbHelper)); var category = new Category { Name = "Ausgang" }; repository.Save(category); Assert.AreEqual(1, repository.Data.Count); Assert.AreSame(category, repository.Data[0]); category.Name = "newName"; repository.Save(category); Assert.AreEqual(1, repository.Data.Count); Assert.AreEqual("newName", repository.Data[0].Name); }
public CategoryBusiness(DatabaseFactory df = null, UnitOfWork uow = null) { DatabaseFactory dfactory = df == null ? new DatabaseFactory() : df; _unitOfWork = uow == null ? new UnitOfWork(dfactory) : uow; _categoryRepository = new CategoryRepository(dfactory); this._formsAuthenticationFactory = new FormsAuthenticationFactory(); }
public ActionResult CreateCategory(Category category) { var rep = new CategoryRepository(); rep.Create(category); return RedirectToAction("Group"); }
public void CategoryRepository_Update() { var dbHelper = new SqliteConnectionCreator(new WindowsSqliteConnectionFactory()); using (var db = dbHelper.GetConnection()) { db.DeleteAll<Category>(); } var repository = new CategoryRepository(new CategoryDataAccess(dbHelper)); var category = new Category { Name = "Ausgang" }; repository.Save(category); repository.Data.Count.ShouldBe(1); repository.Data[0].ShouldBeSameAs(category); category.Name = "newName"; repository.Save(category); repository.Data.Count.ShouldBe(1); repository.Data[0].Name.ShouldBe("newName"); }
private void GetPostService(UnitOfWork uow, out ICategoryService categoryService, out IForumService forumService, out ITopicService topicService, out IPostService postService) { ICategoryRepository cateRepo = new CategoryRepository(uow); IForumRepository forumRepo = new ForumRepository(uow); ITopicRepository topicRepo = new TopicRepository(uow); IPostRepository postRepo = new PostRepository(uow); IForumConfigurationRepository configRepo = new ForumConfigurationRepository(uow); IState request = new DummyRequest(); ILogger logger = new ConsoleLogger(); IUserRepository userRepo = new UserRepository(uow); User user = userRepo.Create(new User { Name = "D. Ummy", ProviderId = "12345678", FullName = "Mr. Doh Ummy", EmailAddress = "[email protected]", Culture = "th-TH", TimeZone = "GMT Standard Time" }); List<IEventSubscriber> subscribers = new List<IEventSubscriber>(); IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request); IUserProvider userProvider = new DummyUserProvider(user); IPermissionService permService = new PermissionService(); IForumConfigurationService confService = new ForumConfigurationService(configRepo); categoryService = new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService); forumService = new ForumService(userProvider, cateRepo, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService); topicService = new TopicService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService); postService = new PostService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService); }
public ActionResult Create() { IRepository<Category> repo = new CategoryRepository(); PostViewModel model = new PostViewModel(repo.GetAll()); return View(model); }
public SecondChoiceDropdownRestStore(CategoryRepository categoryRepository, ContentSearchHandler contentSearchHandler, TemplateResolver templateResolver) { _categoryRepository = categoryRepository; _contentSearchHandler = contentSearchHandler; _templateResolver = templateResolver; }
public RecipeViewModel() { _entities = new DbContextFactory().GetFitnessRecipeEntities(); _authorRepository = new AuthorRepository(_entities); _categoryRepository = new CategoryRepository(_entities); _mealIngredientRepository = new MealIngredientRepository(_entities); _dietRepository = new DietRepository(_entities); }
public HomeController() { authContext = new ApplicationDbContext(); manualRepository = new ManualRepository(new ApplicationDbContext()); categoryRepository = new CategoryRepository(new ApplicationDbContext()); tagRepository = new TagRepository(new ApplicationDbContext()); ratingRepository = new RatingRepository(new ApplicationDbContext()); }
public UnitOfWork(ProjectContext context) { _context = context; Products = new ProductRepository(_context); Categories = new CategoryRepository(_context); Users = new AuthRepository(_context); Carts = new CartRepository(_context); Orders = new OrderRepository(_context); }
public ActionResult Edit(Guid id) { IRepository<Post> postsRepo = new PostRepository(); IRepository<Category> categoriesRepo = new CategoryRepository(); PostViewModel model = new PostViewModel(postsRepo.GetById(id), categoriesRepo.GetAll()); return View(model); }
public ProductDboTest() { repository = new ProductRepository(DbContextFactory); manufacturerRepository = new ManufacturerRepository(DbContextFactory); userRepository = new UserRepository(DbContextFactory); categoryRepository = new CategoryRepository(DbContextFactory); dataService = new ProductDataService(repository, UnitOfWork); }
public void shouldAddCategoryToSystem() { CategoryRepository repository = new CategoryRepository(); var interaction = new AddCategoryInteraction<RAMRepository.CategoryRepository>(new Interactions.RequestModels.AddCategory { Name = CategoryName }, repository); interaction.performAction(); var response = interaction.ResponseModel; Assert.IsFalse(response.Error.HasValue); Assert.IsTrue(repository.Exists(CategoryName)); }
public void shouldCheckForBogusName() { CategoryRepository repository = new CategoryRepository(); var interaction = new AddCategoryInteraction<RAMRepository.CategoryRepository>(new Interactions.RequestModels.AddCategory { Name = "Ga$" }, repository); interaction.performAction(); var response = interaction.ResponseModel; Assert.IsTrue(response.Error.HasValue); Assert.AreEqual<Interactions.ResponseModels.Error.Codes>(response.Error.Value.Code, Interactions.ResponseModels.Error.Codes.CATEGORY_BOGUS_NAME); }
public void AddReturnsId() { var repository = new CategoryRepository(dbFactory, personRepository); var response = repository.Add(new Category()); Assert.IsNotNull(response); Assert.AreEqual(response.Id, 1); }
public override void OnActionExecuting(HttpActionContext context) { CategoryRepository categoryRepository = new CategoryRepository(new MyRoomDbContext()); List<Category> categories = categoryRepository.GetByParentId((int)context.ActionArguments["key"]); if (categories.Count > 0) throw new HttpResponseException(context.Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Please, delete the categories children")); }
public ActionResult Create(FormCollection formCollection) { string name = formCollection.Get("Name"); Category category = new Category() { Name = name }; IRepository<Category> repo = new CategoryRepository(); repo.Save(category); return RedirectToAction("Index"); }
public void shouldNotAlreadyExist() { CategoryRepository repository = new CategoryRepository(); repository.Add(new Entities.Category {Name = CategoryName}); var interaction = new AddCategoryInteraction<RAMRepository.CategoryRepository>(new Interactions.RequestModels.AddCategory { Name = CategoryName }, repository); interaction.performAction(); var response = interaction.ResponseModel; Assert.IsTrue(response.Error.HasValue); Assert.AreEqual<Interactions.ResponseModels.Error.Codes>(response.Error.Value.Code, Interactions.ResponseModels.Error.Codes.CATEGORY_ALREADY_EXISTS); }
public ActionResult Edit(Guid id, FormCollection formCollection) { string name = formCollection.Get("Name"); Category category = new Category() { Id = id, Name = name }; IRepository<Category> repo = new CategoryRepository(); repo.Update(category); return RedirectToAction("Index"); }
private void DropDownInit() { CategoryRepository catRep = new CategoryRepository(); List<category> categList = catRep.Get().ToList(); ViewBag.categories = new SelectList(categList, "categoryID", "name", null); CityRepository cityRep = new CityRepository(); List<city> cityList = cityRep.Get().ToList(); ViewBag.cities = new SelectList(cityList, "cityID", "name", null); }
public Database() { // get config and context from request this.SqlConfig = HttpContext.Current.Items["config"] as SqlConfig; this.SqlContext = HttpContext.Current.Items["context"] as SqlContext; BookEntity = new BookRepository(this.SqlConfig, this.SqlContext); CategoryEntity = new CategoryRepository(this.SqlConfig, this.SqlContext); TagEntity = new TagRepository(this.SqlConfig, this.SqlContext); Tag2BookEntity = new Tag2BookRepository(this.SqlConfig, this.SqlContext); }
public DataAccess() { PollAppDBContext context = new PollAppDBContext(); UserRepository = new UserRepository(context); CategoryRepository = new CategoryRepository(context); TokenRepository = new TokenRepository(context); QuestionRepository = new QuestionRepository(context); AnswerRepository = new AnswerRepository(context); FormRepository = new FormRepository(context); VotedFormsRepository = new VotedFormsRepository(context); }
public void CreateNewCategorySuccessfulTest() { using (UnitOfWork uow = new UnitOfWork()) { CategoryRepository cr = new CategoryRepository(uow.Current); Category c = new Category("Nome categoria di test", "descrizione di test"); cr.Save(c); uow.Commit(); } }
public ActionResult Post(PostViewModel model, HttpPostedFileBase file, HttpPostedFileBase file2, HttpPostedFileBase file3) { try { model.Categories = CategoryRepository.Get().Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }); if (ModelState.IsValid) { var fileObj = new PostFile(); var fileObj2 = new PostFile(); var fileObj3 = new PostFile(); var post = new Post(); var currentuser = UserRepository.Get(Convert.ToInt32(User.Identity.GetUserId())); post.Author = currentuser; var allPosts = PostRepository.Get(); int numberOfPosts = allPosts.Count; post.Category = CategoryRepository.Get(model.CategoryId); if (file != null && file.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder var path = Path.Combine("~/Uploads/", numberOfPosts + fileName); fileObj.FilePath = path; file.SaveAs(Server.MapPath(path)); post.Files.Add(fileObj); } if (file2 != null && file2.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(file2.FileName); // store the file inside ~/App_Data/uploads folder var path = Path.Combine("~/Uploads/", numberOfPosts + fileName); fileObj2.FilePath = path; file2.SaveAs(Server.MapPath(path)); post.Files.Add(fileObj2); } if (file3 != null && file3.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(file3.FileName); // store the file inside ~/App_Data/uploads folder var path = Path.Combine("~/Uploads/", numberOfPosts + fileName); fileObj3.FilePath = path; file3.SaveAs(Server.MapPath(path)); post.Files.Add(fileObj3); } post.Content = model.Content; post.CreatedAt = DateTime.Now; if (model.Formal == "Formal") { post.Formal = true; } else if (model.Formal == "Informal") { post.Formal = false; } post.Title = model.Title; if (!post.Equals(null)) { PostRepository.Add(post); } List <PostFile> listOfNewPost = new List <PostFile>(); fileObj.Post = post; fileObj2.Post = post; fileObj3.Post = post; listOfNewPost.Add(fileObj); listOfNewPost.Add(fileObj2); listOfNewPost.Add(fileObj3); if (listOfNewPost != null || listOfNewPost.Count > 0) { FileRepository.AddThree(listOfNewPost); } return(RedirectToAction("Index", "Feed")); } else { return(View("Index", model)); } } catch (Exception ex) { Debug.WriteLine(ex.Message); return(RedirectToAction("Index")); } }
public BaseCategoryManager() { _generalCategoryRepository = new GeneralCategoryRepository(); _categoryRepository = new CategoryRepository(); _subCategoryRepository = new SubCategoryRepository(); }
public CategoryBs() { categoryRepository = new CategoryRepository(); }
public void Setup() { Repository = new CategoryRepository(Context); }
public UnitOfWork(ProductContext context) { _context = context; Categories = new CategoryRepository(context); Products = new ProductRepository(context); }
public MyPostsController(IConfiguration config) { _postRepo = new PostRepository(config); _categoryRepository = new CategoryRepository(config); _postTagRepo = new PostTagRepository(config); }
public CategoryController(CategoryRepository repository) { this.repository = repository; }
public void GetCategoryById_DescriptonTest(int id) { var result = CategoryRepository.GetCategoryById(id); Assert.AreEqual(Category.Description, result.Description); }
public void GetCategoryById_ShouldFail(int id) { Category result = CategoryRepository.GetCategoryById(id); Assert.AreEqual(CategoryEmpty, result); }
public ProductController(IConfiguration configuration) { repository = new ProductRepository(configuration); categoryRepository = new CategoryRepository(configuration); brandRepository = new BrandRepository(configuration); }
public void Test2() { CategoryRepository r = new CategoryRepository(); var t = r.GetAll(); }
public void Test1() { CategoryRepository r = new CategoryRepository(); output.WriteLine(r.RowCount().ToString()); }
public CategoryController(IConfiguration config) { _categoryRepository = new CategoryRepository(config); }
public ProductController() { _pRep = new ProductRepository(); _cRep = new CategoryRepository(); }
public void GetCategoryById_NameTest(int id) { var result = CategoryRepository.GetCategoryById(id); Assert.AreEqual(Category.Name, result.Name); }
public CategoriesController() { repCategory = new CategoryRepository(db); // ur = new UserRepository(db); }
public PageController() { bRep = new BlogRepository(); pRep = new ProductRepository(); cRep = new CategoryRepository(); }
public DeleteCategoryWork(CategoryRepository categoryRepository, int categoryId) : base(categoryRepository) { m_categoryRepository = categoryRepository; m_categoryId = categoryId; }
public IActionResult Delete(int id) { CategoryRepository.DeleteCategory(id); return(RedirectToAction("Index")); }
private void ConfigureEntityViewModelEntry() { var incomeCategoryFilter = new IncomeCategoryJournalFilterViewModel(); var expenseCategoryFilter = new ExpenseCategoryJournalFilterViewModel { ExcludedIds = CategoryRepository.ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id), HidenByDefault = true }; var commonServices = ServicesConfig.CommonServices; IFileChooserProvider chooserIncomeProvider = new FileChooser("Приход " + DateTime.Now + ".csv"); IFileChooserProvider chooserExpenseProvider = new FileChooser("Расход " + DateTime.Now + ".csv"); var incomeCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <IncomeCategory, IncomeCategoryViewModel>( () => { var incomeCategoryJournalViewModel = new SimpleEntityJournalViewModel <IncomeCategory, IncomeCategoryViewModel>( x => x.Name, () => new IncomeCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, commonServices, chooserIncomeProvider, incomeCategoryFilter ), node => new IncomeCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, commonServices, chooserIncomeProvider, incomeCategoryFilter ), UnitOfWorkFactory.GetDefaultFactory, commonServices ) { SelectionMode = JournalSelectionMode.Single }; return(incomeCategoryJournalViewModel); }); var expenseCategoryAutocompleteSelectorFactory = new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>( () => { var expenseCategoryJournalViewModel = new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>( x => x.Name, () => new ExpenseCategoryViewModel( EntityUoWBuilder.ForCreate(), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, chooserExpenseProvider, expenseCategoryFilter ), node => new ExpenseCategoryViewModel( EntityUoWBuilder.ForOpen(node.Id), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices, chooserExpenseProvider, expenseCategoryFilter ), UnitOfWorkFactory.GetDefaultFactory, ServicesConfig.CommonServices ) { SelectionMode = JournalSelectionMode.Single }; expenseCategoryJournalViewModel.SetFilter(expenseCategoryFilter, filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray()))); return(expenseCategoryJournalViewModel); }); entityVMEntryCashIncomeCategory.SetEntityAutocompleteSelectorFactory(incomeCategoryAutocompleteSelectorFactory); entityVMEntryCashExpenseCategory.SetEntityAutocompleteSelectorFactory(expenseCategoryAutocompleteSelectorFactory); }
public CategoryController() { crep = new CategoryRepository(); }
public SnippetController(ApplicationDbContext context, IConfiguration configuration) { _snippetRepository = new SnippetRepository(context, configuration); _userProfileRepository = new UserProfileRepository(context); _categoryRepository = new CategoryRepository(context); }
// Dependency Injection public CategoriesController(IHostingEnvironment environment, IConfiguration configuration, CategoryRepository repository) { this.Repository = repository; }
public void AddNewCategory(string inCategoryName) { CategoryRepository.getInstance().addCategory(new Category(inCategoryName)); List <Category> list = GetCategoryList(); }
private void BindLinkCategories() { Category.DataSource = CategoryRepository.FindByType(Link.CategoryType); Category.DataBind(); }
public PostController(IConfiguration config) { _postRepository = new PostRepository(config); _categoryRepository = new CategoryRepository(config); }
public ActionResult Index(string category) { var item = CategoryRepository.GetAll().FirstOrDefault(c => c.UrlSegment == category); return(View(item)); }
public void CategoryExists_Test() { var result = CategoryRepository.Exists(Category); Assert.IsTrue(result); }
public CategoryController(CategoryRepository categoryRepository) { _categoryRepository = categoryRepository; }
public CategoryService(IMapper mapper) { _categoryRepository = new CategoryRepository(mapper); _newsItemRepository = new NewsItemRepository(mapper); }