示例#1
0
        public async Task <IEnumerable <dynamic> > GetPaginatedResultAsync(string schemaName, string tableName)
        {
            try
            {
                var repository = new ViewRepository(schemaName, tableName, this.AppUser.Tenant, this.AppUser.LoginId, this.AppUser.UserId);
                return(await repository.GetPaginatedResultAsync().ConfigureAwait(false));
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException
                      (
                          new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
 public void WhenLoadInvokedAndNoFactoryIsRegistered_NullIsReturned()
 {
     Mock<IContainer> containerMock = new Mock<IContainer>();
     ViewRepository repository = new ViewRepository(containerMock.Object);
     String result = repository.Load<string, string>("hello");
     Assert.AreEqual(null, result);
 }
示例#3
0
        private void PrepareContractor()
        {
            ViewRepository repo = new ViewRepository();

            try
            {
                var total = repo.ContractorTotalHours()
                            .Where(s => s.Id == Convert.ToInt16(comboBox1.SelectedValue))
                            .FirstOrDefault().Total;
                txtTotalHoursWorked.Text = total.ToString();
            }
            catch
            {
                txtTotalHoursWorked.Text = "0";
            }

            var items = repo.ContractTimeSheetMonths()
                        .Where(s => s.ContractorId == Convert.ToInt16(comboBox1.SelectedValue)).ToList();

            dataGridView1.DataSource           = items;
            dataGridView1.Columns[0].Visible   = false;
            dataGridView1.Columns[1].Visible   = false;
            dataGridView1.RowHeadersVisible    = false;
            dataGridView1.ColumnHeadersVisible = false;
            dataGridView1.SelectionMode        = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.MultiSelect          = false;
            GetMonth();

            queryResult = repo.HDMQuery1().Where(x => x.ContractorId == Convert.ToInt16(comboBox1.SelectedValue)).ToList();

            currentContractor = new LookupRepository().GetContractors().FirstOrDefault(e => e.ID == Convert.ToInt16(comboBox1.SelectedValue));
            Populate();
        }
 public ChatController()
 {
     viewRepository           = new ViewRepository(dataContext);
     chatRepository           = new ChatRepository(dataContext);
     userRepository           = new UserRepository(dataContext);
     privateMessageRepository = new PrivateMessageRepository(dataContext);
 }
示例#5
0
 public UnitOfWork(XdContext context)
 {
     _context            = context;
     AddressInformations = new AddressInformationRepository(_context);
     AppUsers            = new AppUserRepository(_context);
     AppUserRoles        = new AppUserRoleRepository(_context);
     Contacts            = new ContactRepository(_context);
     Credentials         = new CredentialsRepository(_context);
     DbTypes             = new DbTypeRepository(_context);
     Entities            = new EntityRepository(_context);
     EntityTypes         = new EntityTypeRepository(_context);
     Fields = new FieldRepository(_context);
     FieldRequirementLevels = new FieldRequirementLevelRepository(_context);
     FieldTypes             = new FieldTypeRepository(_context);
     Forms           = new FormRepository(_context);
     FormTypes       = new FormTypeRepository(_context);
     Genders         = new GenderRepository(_context);
     MaritalStatuses = new MaritalStatusRepository(_context);
     MenuItems       = new MenuItemRepository(_context);
     Roles           = new RoleRepository(_context);
     Tabs            = new TabRepository(_context);
     Titles          = new TitleRepository(_context);
     Views           = new ViewRepository(_context);
     ViewTypes       = new ViewTypeRepository(_context);
 }
示例#6
0
        private void LoadGrid()
        {
            ViewRepository repository = new ViewRepository();
            var            gridItems  = repository.GetNotWorking().Where(e => e.Month == GlobalValues.Instance.CurrentMonth).ToList();

            dataGridView1.DataSource         = gridItems;
            dataGridView1.Columns[2].Visible = false;
            dataGridView1.Columns[8].Visible = false;
            dataGridView1.Columns[7].Visible = fiveweek;

            for (int i = 0; i < gridItems.Count; i++)
            {
                if (gridItems[i].Week1 == 0)
                {
                    dataGridView1.Rows[i].Cells[3].Style.BackColor = Color.Red;
                }
                if (gridItems[i].Week2 == 0)
                {
                    dataGridView1.Rows[i].Cells[4].Style.BackColor = Color.Red;
                }
                if (gridItems[i].Week3 == 0)
                {
                    dataGridView1.Rows[i].Cells[5].Style.BackColor = Color.Red;
                }
                if (gridItems[i].Week4 == 0)
                {
                    dataGridView1.Rows[i].Cells[6].Style.BackColor = Color.Red;
                }
                if (gridItems[i].Week5 == 0)
                {
                    dataGridView1.Rows[i].Cells[7].Style.BackColor = Color.Red;
                }
            }
        }
 public ViewController()
 {
     groupChatRepository = new GroupChatRepository(dataContext);
     chatRepository      = new ChatRepository(dataContext);
     viewRepository      = new ViewRepository(dataContext);
     userRepository      = new UserRepository(dataContext);
 }
示例#8
0
        public async Task <IEnumerable <DisplayField> > GetLookupFieldsAsync(string schemaName, string tableName, [FromBody] List <Filter> filters)
        {
            try
            {
                var repository = new ViewRepository(schemaName, tableName, this.AppUser.Tenant, this.AppUser.LoginId, this.AppUser.UserId);
                return(await repository.GetLookupFieldsAsync(filters).ConfigureAwait(false));
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException
                      (
                          new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
示例#9
0
        public ActionResult Edit(long?view_id, string view_friendly_name, string view_name, string view_path)
        {
            using (ViewRepository view_repository = new ViewRepository())
            {
                if (view_id.HasValue)
                {
                    view_repository.Update(view_id.Value, view_friendly_name, view_name, view_path, CurrentUser.user_domain);
                }
                else
                {
                    view_id = view_repository.CreateGlobalID();

                    string new_view_name = Transliterator.Translite(view_friendly_name);

                    if (view_repository.Exists(new_view_name, CurrentUser.user_domain))
                    {
                        new_view_name = new_view_name + "-" + view_id.ToString();
                    }

                    view_repository.Create(view_id.Value, view_friendly_name, new_view_name, view_path, CurrentUser.user_domain);
                }
            }

            return(RedirectToAction("Index"));
        }
示例#10
0
        public FormServer(ServerDescription description)
        {
            Init();

            textName.Text = description.Name;

            checkVideo.Checked  = (description.Types & DlnaMediaTypes.Video) == DlnaMediaTypes.Video;
            checkAudio.Checked  = (description.Types & DlnaMediaTypes.Audio) == DlnaMediaTypes.Audio;
            checkImages.Checked = (description.Types & DlnaMediaTypes.Image) == DlnaMediaTypes.Image;

            foreach (var i in comboOrder.Items)
            {
                if (((IItemComparer)i).Name == description.Order)
                {
                    comboOrder.SelectedItem = i;
                    break;
                }
            }
            checkOrderDescending.Checked = description.OrderDescending;

            foreach (var v in description.Views)
            {
                var i = new ListViewItem(new string[] { v, ViewRepository.Lookup(v).Description });
                listViews.Items.Add(i);
            }
            foreach (var d in description.Directories)
            {
                var i = new ListViewItem(d);
                listDirectories.Items.Add(i);
            }

            SizeDirectoryColumn();
            SizeViewsColumns();
        }
示例#11
0
        public IEnumerable <dynamic> GetAll(string schemaName, string tableName)
        {
            try
            {
                var repository = new ViewRepository(schemaName, tableName, this.MetaUser.Tenant, this.MetaUser.LoginId,
                                                    this.MetaUser.UserId);
                return(repository.Get());
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
示例#12
0
        public long CountWhere(string schemaName, string tableName, [FromBody] JArray filters)
        {
            try
            {
                var f          = Filter.FromJArray(filters);
                var repository = new ViewRepository(schemaName, tableName, this.MetaUser.Tenant, this.MetaUser.LoginId,
                                                    this.MetaUser.UserId);
                return(repository.CountWhere(f));
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
示例#13
0
 public void BeforeEachTest()
 {
     mockConfiguration = new Mock<IProvideCouchConfiguration>();
     mockCouchUriBuilder = new Mock<CouchUriBuilder>(new object[] {mockConfiguration.Object});
     viewRepository = new ViewRepository<TestDocument>(mockCouchUriBuilder.Object,
                                                                 mockJsonClient.Object);
     documentUri = new Uri("http://somecouchserver:1433/db/someid");
 }
        public void WhenLoadInvokedAndNoFactoryIsRegistered_NullIsReturned()
        {
            Mock <IContainer> containerMock = new Mock <IContainer>();
            ViewRepository    repository    = new ViewRepository(containerMock.Object);
            String            result        = repository.Load <string, string>("hello");

            Assert.AreEqual(null, result);
        }
示例#15
0
        public ActionResult Remove(long view_id)
        {
            using (ViewRepository view_repository = new ViewRepository())
            {
                view_repository.Remove(view_id);
            }

            return(RedirectToAction("Index"));
        }
示例#16
0
        public void RegisterView_ShouldThrowException_GivenIncorrectTypes(Type viewType, Type viewModelType)
        {
            // Arrange
            var viewRepository = new ViewRepository();

            // Act
            // Assert
            Assert.That(() => viewRepository.RegisterView(viewType, viewModelType), Throws.ArgumentException);
        }
示例#17
0
        public ActionResult Index()
        {
            using (ViewRepository view_repository = new ViewRepository())
            {
                ViewBag.items = view_repository.All(CurrentUser.user_domain);
            }

            return(View());
        }
示例#18
0
        public FormServer(ServerDescription description)
        {
            Init();

            textName.Text = description.Name;

            checkVideo.Checked  = (description.Types & DlnaMediaTypes.Video) == DlnaMediaTypes.Video;
            checkAudio.Checked  = (description.Types & DlnaMediaTypes.Audio) == DlnaMediaTypes.Audio;
            checkImages.Checked = (description.Types & DlnaMediaTypes.Image) == DlnaMediaTypes.Image;

            foreach (var i in comboOrder.Items)
            {
                if (((IItemComparer)i).Name == description.Order)
                {
                    comboOrder.SelectedItem = i;
                    break;
                }
            }
            checkOrderDescending.Checked = description.OrderDescending;

            foreach (var v in description.Views)
            {
                var i = new ListViewItem(new string[] { v, ViewRepository.Lookup(v).Description });
                listViews.Items.Add(i);
            }
            foreach (var d in description.Directories)
            {
                var i = new ListViewItem(d);
                listDirectories.Items.Add(i);
            }
            var t = comboNewRestriction.Items[0].ToString();

            foreach (var r in description.Macs)
            {
                var i = listRestrictions.Items.Add(r);
                i.Tag = 0;
                i.SubItems.Add(t);
            }
            t = comboNewRestriction.Items[1].ToString();
            foreach (var r in description.Ips)
            {
                var i = listRestrictions.Items.Add(r);
                i.Tag = 1;
                i.SubItems.Add(t);
            }
            t = comboNewRestriction.Items[2].ToString();
            foreach (var r in description.UserAgents)
            {
                var i = listRestrictions.Items.Add(r);
                i.Tag = 2;
                i.SubItems.Add(t);
            }

            SizeDirectoryColumn();
            SizeColumns(listViews);
        }
示例#19
0
 public void AddView(string name)
 {
     try {
         views.Add(ViewRepository.Lookup(name));
     }
     catch (Exception ex) {
         _logger.Error("Failed to add view", ex);
         throw;
     }
 }
示例#20
0
        public void CreateView_ShouldThrowException_GivenViewModelForNotRegisteredView()
        {
            // Arrange
            var viewRepository = new ViewRepository();
            var viewModel      = new TestViewModel();

            // Act
            // Assert
            Assert.That(() => viewRepository.CreateView(viewModel), Throws.ArgumentException);
        }
 public void WhenLoadInvokedAndFactoryIsRegistered_ViewIsReturned()
 {
     Mock<IContainer> containerMock = new Mock<IContainer>();
     Mock<IViewFactory<string, string>> viewFactoryMock = new Mock<IViewFactory<string, string>>();
     containerMock.Setup(x => x.TryGetInstance<IViewFactory<string, string>>()).Returns(viewFactoryMock.Object);
     viewFactoryMock.Setup(x => x.Load("hello")).Returns("hi");
     ViewRepository repository = new ViewRepository(containerMock.Object);
     String result = repository.Load<string, string>("hello");
     Assert.AreEqual("hi", result);
 }
示例#22
0
        public void GreetMeTest()
        {
            ViewRepository repo             = new ViewRepository();
            string         expectedGreeting = "Hello Anton";
            string         actualGreeting;

            actualGreeting = repo.GreetMe("Anton");

            Assert.AreEqual(expectedGreeting, actualGreeting);
        }
示例#23
0
        private void GetMonth()
        {
            ViewRepository repo = new ViewRepository();

            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }
            var record = repo.HDMQuery1().Where(x => x.ContractorId == Convert.ToInt16(comboBox1.SelectedValue) &&
                                                x.Month == Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[1].Value)).FirstOrDefault();
        }
 public CategoryService(CategoryRepository categoryRepository, StudentCourseRepository studentCourseRepository,
                        CourseRepository courseRepository, ViewRepository viewRepository,
                        FeedbackRepository feedbackRepository, UserRepository userRepository)
 {
     this.categoryRepository      = categoryRepository;
     this.studentCourseRepository = studentCourseRepository;
     this.courseRepository        = courseRepository;
     this.viewRepository          = viewRepository;
     this.feedbackRepository      = feedbackRepository;
     this.userRepository          = userRepository;
 }
示例#25
0
        private void AddViewItems()
        {
            var items = from v in ViewRepository.ListItems()
                        orderby v.Key
                        select v.Value;

            foreach (var v in items)
            {
                comboNewView.Items.Add(v);
            }
        }
示例#26
0
        public ActionResult UpdateOrder(long[] ids, long[] orders)
        {
            using (ViewRepository view_repository = new ViewRepository())
            {
                for (int i = 0; i < ids.Length; i++)
                {
                    view_repository.UpdateOrder(ids[i], orders[i]);
                }
            }

            return(new EmptyResult());
        }
        public void WhenLoadInvokedAndFactoryIsRegistered_ViewIsReturned()
        {
            Mock <IContainer> containerMock = new Mock <IContainer>();
            Mock <IViewFactory <string, string> > viewFactoryMock = new Mock <IViewFactory <string, string> >();

            containerMock.Setup(x => x.TryGetInstance <IViewFactory <string, string> >()).Returns(viewFactoryMock.Object);
            viewFactoryMock.Setup(x => x.Load("hello")).Returns("hi");
            ViewRepository repository = new ViewRepository(containerMock.Object);
            String         result     = repository.Load <string, string>("hello");

            Assert.AreEqual("hi", result);
        }
示例#28
0
        public ActionResult Edit(long?view_id)
        {
            using (ViewRepository view_repository = new ViewRepository())
            {
                if (view_id.HasValue)
                {
                    ViewBag.item = view_repository.GetByID(view_id.Value);
                }
            }

            return(View());
        }
示例#29
0
        public void GetAllTasks_MockDbSetTasksAndContext_AndGetAllTasks()
        {
            //assign
            MiniAutoFixture miniAutoFixture = new MiniAutoFixture();

            miniAutoFixture.Initialize();

            User user1 = DbSetTools.CreateUser(1, miniAutoFixture);
            User user2 = DbSetTools.CreateUser(1, miniAutoFixture);

            List <Task> tasksCollection = DbSetTools.CreateTaskList(1, user1, 10, miniAutoFixture)
                                          .Concat(DbSetTools.CreateTaskList(11, user2, 20, miniAutoFixture))
                                          .ToList();

            IQueryable <Task> tasks = tasksCollection.AsQueryable();

            var mockDbSet = new Mock <DbSet <Task> >();

            mockDbSet.As <IQueryable <Task> >().Setup(m => m.Provider).Returns(tasks.Provider);
            mockDbSet.As <IQueryable <Task> >().Setup(m => m.Expression).Returns(tasks.Expression);
            mockDbSet.As <IQueryable <Task> >().Setup(m => m.ElementType).Returns(tasks.ElementType);
            mockDbSet.As <IQueryable <Task> >().Setup(m => m.GetEnumerator()).Returns(tasks.GetEnumerator());

            var mockContext = new Mock <OrganizerContext>();

            mockContext.Setup(c => c.Tasks).Returns(mockDbSet.Object);
            var            logger         = new Mock <ILogger <ViewRepository> >();
            ViewRepository viewRepository = new ViewRepository(mockContext.Object, logger.Object);

            //action
            IEnumerable <TaskView> taskList = viewRepository.GetAllTasks();

            //assert
            Assert.Equal(tasks.Count(), taskList.Count());
            tasks.ToList().ForEach(task =>
            {
                Assert.Equal
                (
                    taskList.Count
                    (
                        taskView =>
                        taskView.Id == task.Id &&
                        taskView.Text == task.Text &&
                        taskView.Date == task.Date &&
                        taskView.Deleted == task.Deleted &&
                        taskView.Done == task.Done
                    ),
                    1
                );
            }
                                   );
        }
示例#30
0
文件: Program.cs 项目: jxp/simpleDLNA
        private static void ListViews()
        {
            var items = from v in ViewRepository.ListItems()
                        orderby v.Key
                        select v.Value;

            Console.WriteLine("Available views:");
            Console.WriteLine("----------------");
            Console.WriteLine();
            foreach (var i in items)
            {
                Console.WriteLine("  - " + i);
                Console.WriteLine();
            }
        }
        public void Handle(string id, IEnumerable <TEventBase> events)
        {
            var materializedEvents = events?.ToList() ?? new List <TEventBase>();

            if (!AnyEventsToHandle(materializedEvents))
            {
                return;
            }

            var view = ViewRepository.Read <TView>(id) ?? new TView();

            view = Handle(materializedEvents, view);

            ViewRepository.Commit(id, view);
        }
示例#32
0
        public void RegisterViewsFromCurrentlyLoadedAssemblies_ShouldRegisterViewsWithAttribute()
        {
            // Arrange
            var viewRepository = new ViewRepository();

            // Act
            viewRepository.RegisterViewsFromCurrentlyLoadedAssemblies();

            // Assert
            var viewModel = new TestViewModel();
            var view      = viewRepository.CreateView(viewModel);

            Assert.That(view, Is.Not.Null);
            Assert.That(view, Is.TypeOf <AttributedTestView>());
        }
        public void SetUp()
        {
            _views = new Dictionary <Type, View>();
            _view  = new FakeView();

            _mockContext = new Mock <IDataContext>();
            _mockContext.Setup(p => p.Views).Returns(_views);

            _mockFactory = new Mock <IViewFactory>();
            _mockFactory.Setup(p => p.Create <FakeView>())
            .Returns(_view);

            _repository = new ViewRepository(
                _mockContext.Object,
                _mockFactory.Object);
        }
		public static ViewRepository GetViewRepository()
		{
			var repository = new ViewRepository();
			repository.UnitOfWork = GetUnitOfWork();
			return repository;
		}
		public static ViewRepository GetViewRepository(IUnitOfWork unitOfWork)
		{
			var repository = new ViewRepository();
			repository.UnitOfWork = unitOfWork;
			return repository;
		}