Ejemplo n.º 1
0
        /*
         * class Class1
         * {
         *  public string RowNews { get; set; }
         *  public string TopName { get; set; }
         *  public string LowName { get; set; }
         *  public Image ImagePath { get; set; }
         *  public Class1()
         *  {
         *      TopName = "Top";
         *      LowName = "1\n"+"2\n";
         *     // ImagePath = @"C:\Users\Xsinser\Desktop\news.jpg";
         *      ImagePath = new Image { Source = "cabel.png" };
         *      RowNews = "30";
         *  }
         *
         * }
         */
        public News()
        {
            InitializeComponent();
            BindingContext = new ViewsModel("Новости");

            //  var list = new List<Class1>();
            // list.Add(new Class1());
            //listView.ItemsSource = list;
        }
Ejemplo n.º 2
0
        public void SetProperties(ViewEngine.FindViews.Message findViewMessage, View.Render.Message viewRenderMessage)
        {
            var model = new ViewsModel(findViewMessage, viewRenderMessage);

            Assert.Equal(findViewMessage.ViewName, model.ViewName);
            Assert.Equal(findViewMessage.MasterName, model.MasterName);
            Assert.Equal(findViewMessage.IsPartial, model.IsPartial);
            Assert.Equal(findViewMessage.BaseType, model.ViewEngineType);
            Assert.Equal(findViewMessage.UseCache, model.UseCache);
            Assert.Equal(findViewMessage.IsFound, model.IsFound);
            Assert.Equal(findViewMessage.SearchedLocations, model.SearchedLocations);
            Assert.NotNull(model.ViewModelSummary);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The get new view.
        /// </summary>
        /// <param name="_taskTypes">
        /// </param>
        /// <param name="_statuses">
        /// </param>
        /// <param name="_contexts">
        /// </param>
        /// <returns>
        /// The <see cref="ViewsModel"/>.
        /// </returns>
        public static ViewsModel GetNewView(
            ObservableCollection <TypeOfTask> _taskTypes,
            ObservableCollection <StatusTask> _statuses,
            IEnumerable <Context> _contexts)
        {
            var nv = new ViewsModel
            {
                GUID                = Guid.NewGuid().ToString(),
                NameOfView          = "Название нового вида",
                ViewTypesOfTasks    = new ObservableCollection <ViewVisibleTypes>(),
                ViewStatusOfTasks   = new ObservableCollection <ViewVisibleStatuses>(),
                ViewContextsOfTasks = new ObservableCollection <ViewVisibleContexts>()
            };

            // Добавляем к виду типы задач
            foreach (var persTaskType in _taskTypes)
            {
                nv.ViewTypesOfTasks.Add(new ViewVisibleTypes()
                {
                    taskType = persTaskType, isVisible = false
                });
            }

            // Добавляем к виду статусы
            foreach (var statusTask in _statuses)
            {
                nv.ViewStatusOfTasks.Add(new ViewVisibleStatuses()
                {
                    taskStatus = statusTask, isVisible = false
                });
            }

            // Добавляем к виду контексты
            foreach (var context in _contexts)
            {
                nv.ViewContextsOfTasks.Add(new ViewVisibleContexts()
                {
                    taskContext = context, isVisible = false
                });
            }

            return(nv);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get Loction Model of   particular Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ViewsModel GetView(long id)
        {
            ViewsModel viewModel = db.Fetch <ViewsModel>(new Sql().Select("*").From(TABLE_NAME).Where <ViewsModel>(x => x.ViewId == id, DatabaseContext.SqlSyntax)).FirstOrDefault();

            return(viewModel);
        }
        /// <summary>
        /// Initializes a new instance of the AutofocusViewModel class.
        /// </summary>
        /// <param name="_pers">
        /// The _pers.
        /// </param>
        /// <param name="selectedView">
        /// </param>
        public AutofocusViewModel(Pers _pers, ViewsModel selectedView)
        {
            this.PersProperty         = _pers;
            this.SelectedViewProperty = selectedView;
            Messenger.Default.Register <string>(
                this,
                _string =>
            {
                if (_string == "Ок в задаче нажимается")
                {
                    // this.TasksProperty.MoveCurrentToPrevious();

                    // this.next();
                }

                if (_string == "Ок в задаче")
                {
                    this.IsEditOrAddOpenProperty = false;
                    this.TasksProperty.Refresh();
                    if (this.TasksProperty.CurrentItem == null)
                    {
                        this.next();
                    }
                }
            });

            this.TasksProperty = (ListCollectionView)CollectionViewSource.GetDefaultView(this.PersProperty.Tasks);
            this.TasksProperty.SortDescriptions.Add(
                new SortDescription("PositionProperty", ListSortDirection.Ascending));
            this.TasksProperty.MoveCurrentToFirst();
            this.SelectedTaskProperty          = (Task)this.TasksProperty.CurrentItem;
            this.TasksProperty.CurrentChanged +=
                (sender, args) => { this.SelectedTaskProperty = (Task)this.TasksProperty.CurrentItem; };

            // Фильтр
            this.TasksProperty.Filter = o =>
            {
                var task       = o as Task;
                var begin      = task.BeginDateProperty;
                var dateOfDone = string.IsNullOrEmpty(task.DateOfDone)
                    ? DateTime.MinValue
                    : DateTime.Parse(task.DateOfDone);

                if (this.SelectedViewProperty != null)
                {
                    if (this.SelectedViewProperty.ViewTypesOfTasks == null ||
                        this.SelectedViewProperty.ViewTypesOfTasks.Count == 0)
                    {
                    }
                    else
                    {
                        // если не соответствует нужным типам задач
                        if (
                            this.SelectedViewProperty.ViewTypesOfTasks.Any(
                                n => n.taskType == task.TaskType && n.isVisible == true) == false)
                        {
                            return(false);
                        }

                        // если не соответствует нужным статусам
                        if (
                            this.SelectedViewProperty.ViewStatusOfTasks.Any(
                                n => n.taskStatus == task.TaskStatus && n.isVisible == true) == false)
                        {
                            return(false);
                        }

                        // если не соответствует нужным контекстам
                        if (
                            this.SelectedViewProperty.ViewContextsOfTasks.Any(
                                n => n.taskContext == task.TaskContext && n.isVisible == true) == false)
                        {
                            return(false);
                        }
                    }
                }

                if (begin <= this.DateOfBeginProperty)
                {
                    if (dateOfDone > this.DateOfBeginProperty || dateOfDone == DateTime.MinValue)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            };

            Messenger.Default.Send <Pers>(this.PersProperty);
        }
Ejemplo n.º 6
0
        public ActionResult DisplayThread(int threadId, bool isLiked = false, bool isWatched = false)
        {
            //  var thread = _unitOfWork.ThreadWithComments(threadId);
            //lazy to change views
            //will optimize later to one call

            var threadSingle = _unitOfWork.ThreadRepository.GetById(threadId);
            var comments     = _unitOfWork.CommentRepository.Get(x => x.Thread_ThreadId == threadId).OrderByDescending(x => x.CommentedOn).ToList();

            // get other post by same user
            var totalPostCountByUser = _unitOfWork.ThreadRepository.Get(x => x.Username == threadSingle.Username).Count();
            var posts = _unitOfWork.ThreadRepository.Get(x => x.Username == threadSingle.Username).OrderByDescending(x => x.SubmittedOn).Take(Constants.BlocksizeUserSpecificThreads).ToList();

            if (isLiked)
            {
                ViewBag.Liked = true;
            }
            if (isWatched)
            {
                ViewBag.Watched = true;
            }
            var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions()
            {
                IsolationLevel = IsolationLevel.ReadCommitted
            });

            try
            {
                using (scope)
                {
                    threadSingle.Views = threadSingle.Views + 1;
                    _unitOfWork.ThreadRepository.Update(threadSingle);
                    _unitOfWork.Save();

                    var viewsModel = new ViewsModel()
                    {
                        ThreadId  = threadId,
                        ViewedBy  = Request.Cookies["LogOnCookie"] == null ? "Anonymous" : Request.Cookies["LogOnCookie"].Values["username"],
                        ViewedOn  = DateTime.Now,
                        IpAddress = GetIp(),
                        Browser   = Request.Browser.Browser
                    };
                    //only logged in users are recorded
                    if (Request.Cookies["LogOnCookie"] != null)
                    {
                        _unitOfWork.ViewsRepository.Insert(viewsModel);
                        _unitOfWork.Save();
                    }

                    ViewBag.TotalPostByUser = totalPostCountByUser;
                    ViewBag.Comments        = comments;
                    ViewBag.Posts           = posts;
                    ViewBag.CurrentPage     = 1;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                scope.Dispose();
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }
            // Response.Cache.SetCacheability(HttpCacheability.NoCache);
            CacheImplementation.UpdateCacheItem(CacheImplementation.RecentThreads, threadId, "Views", null);
            CacheImplementation.UpdateCacheItem(CacheImplementation.MostViewedThreads, threadId, "Views", null);
            //CacheImplementation.UpdateCacheItem(CacheImplementation.MostLikedThreads, threadId, "Likes", null);
            CacheImplementation.UpdateCacheItem(CacheImplementation.MostCommentedThreads, threadId, "Comments", null);
            return(View(threadSingle));
        }