public void GenericTools_RepositoryHandler_AddUpdateDelete() { //register sample service RepositoryHandler.Add(new SampleModelRepository()); var item = RepositoryHandler.Get <SampleModelRepository>().Add(new SampleModel() { Age = 50 }); MakeSure.That(item.Age).Is(50); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Get(i => i == item)).Is(item); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(4); var newItem = RepositoryHandler.Get <SampleModelRepository>().Update(item, new SampleModel() { Age = 53 }); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Get(i => i == newItem)).Is(newItem); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(4); RepositoryHandler.Get <SampleModelRepository>().Delete(i => i.Age > 40); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(3); MakeSure.That(() => RepositoryHandler.Get <SampleModelRepository>().SaveChanges()).DoesNotThrow(); }
public ActionResult CreateRole(Role role) { if (ModelState.IsValid) { RolesHandler.Add(role); } return(RedirectToAction("Roles")); }
public ActionResult CreatePosition(Position position) { if (ModelState.IsValid) { _positionsHandler.Add(position); } return(RedirectToAction("Positions")); }
public ActionResult CreateDocumentType(DocumentType documentType) { if (ModelState.IsValid) { DocumentTypesHandler.Add(documentType); return(RedirectToAction("DocumentTypes")); } return(View("Create/CreateDocumentType", documentType)); }
public void GenericTools_RepositoryHandler_GetAll() { //register sample service RepositoryHandler.Add(new SampleModelRepository()); var count = RepositoryHandler.Get <SampleModelRepository>().GetAll().Count(); MakeSure.That(count).Is(3); var count2 = RepositoryHandler.Get <SampleModelRepository>().GetAll(i => i.Age > 17).Count(); MakeSure.That(count2).Is(2); }
public void GenericTools_RepositoryHandler_Get() { //register sample service RepositoryHandler.Add(new SampleModelRepository()); var sampleModel = RepositoryHandler.Get <SampleModelRepository>().Get(); MakeSure.That(sampleModel).IsNot(null); MakeSure.That(sampleModel.Age).Is(1); var sampleModel2 = RepositoryHandler.Get <SampleModelRepository>().Get(i => i.Age > 17); MakeSure.That(sampleModel2.Age).Is(22); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>().Count).Is(3); }
public void GenericTools_RepositoryHandler_RegisterMultiple() { MakeSure.That(() => { var items = RepositoryHandler.Add( new SampleModelRepository(), new SampleModelRepository(), new SampleModelRepository() ); MakeSure.That(items.Count()).Is(3); }).DoesNotThrow(); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>()).IsNot(null); }
public User Register(RegisterModel registerModel) { if (_usersRepository.GetAll(user => user.UserName == registerModel.Login).Count() == 0) { _usersRepository.Add(new User { FirstName = registerModel.FirstName, LastName = registerModel.LastName, Patronymic = registerModel.Patronymic, UserName = registerModel.Login, PositionId = registerModel.PositionId, Password = registerModel.Password, Email = registerModel.Email, RoleId = 2 //user }); return(_usersRepository.GetAll(user => user.UserName == registerModel.Login).First()); } return(null); }
public void GenericTools_RepositoryHandler() { var vm = RepositoryHandler.Add(new SampleModelRepository()); MakeSure.That(RepositoryHandler.Get <SampleModelRepository>()).Is((SampleModelRepository)vm); }
public ActionResult CreateTemplate(DocumentTemplate template) { TemplatesHandler.Add(template); return(RedirectToAction("DocumentTemplates", "Admin")); }