예제 #1
0
        public string GetNavigateUrl(object obj)
        {
            TopicInfoDto item = (TopicInfoDto)obj;
            string       url  = string.Format("{0}?{1}={2}", TopicPage.PageUrl, TopicPage.QryInstanceId, item.TopicId);

            return(GetUrl(url));
        }
예제 #2
0
        public IFacadeUpdateResult <TopicData> CreateTopic(TopicInfoDto topic, PostInfoDto post)
        {
            // Save topic
            UnitOfWork.BeginTransaction();
            FacadeUpdateResult <TopicData> result = TopicSystem.SaveNewTopic(topic);

            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
                TopicData savedTopic = result.Result;
                // set post.TopicId
                post.TopicId = savedTopic.Id;
                // Save Post
                PostSystem postSystem = new PostSystem(UnitOfWork);
                UnitOfWork.BeginTransaction();
                IFacadeUpdateResult <PostData> resultPost = postSystem.SaveNewPost(post);
                if (resultPost.IsSuccessful)
                {
                    UnitOfWork.CommitTransaction();
                }
                else
                {
                    UnitOfWork.RollbackTransaction();
                }
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }

            return(result);
        }
예제 #3
0
        protected void btnPost_Click(object sender, EventArgs e)
        {
            string title   = txtTitle.Text.Trim();
            string content = edContent.Content.Trim();

            if (title.Length > 0 && content.Length > 0)
            {
                TopicInfoDto topic = new TopicInfoDto();
                topic.IssuedById = CurrentUserContext.User.UserId;
                topic.Title      = title;

                PostInfoDto post = new PostInfoDto();
                post.Content    = content;
                post.IssuedById = CurrentUserContext.User.UserId;

                IFacadeUpdateResult <TopicData> result = SaveCreatedTopic(topic, post);
                if (result.IsSuccessful)
                {
                    Response.Redirect(GetUrl(TopicList.PageUrl), true);
                }
                else
                {
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
        }
예제 #4
0
 private IFacadeUpdateResult <TopicData> SaveCreatedTopic(TopicInfoDto topic, PostInfoDto post)
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
     {
         TopicFacade facade = new TopicFacade(uow);
         IFacadeUpdateResult <TopicData> result = facade.CreateTopic(topic, post);
         return(result);
     }
 }
예제 #5
0
        internal FacadeUpdateResult <TopicData> SaveNewTopic(TopicInfoDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <TopicData> result = new FacadeUpdateResult <TopicData>();
            ITopicService service  = UnitOfWork.GetService <ITopicService>();
            Topic         instance = RetrieveOrNew <TopicData, Topic, ITopicService>(result.ValidationResult, dto.TopicId);

            if (result.IsSuccessful)
            {
                instance.Title      = dto.Title;
                instance.IssuedById = dto.IssuedById;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <TopicData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
예제 #6
0
        public string GetLastPostTime(object obj)
        {
            TopicInfoDto item = (TopicInfoDto)obj;

            return(item.LastPostTime.ToString(WebContext.Current.ApplicationOption.DateTimeFormat));
        }
예제 #7
0
        public string GetLastPostBy(object obj)
        {
            TopicInfoDto item = (TopicInfoDto)obj;

            return(string.Format("by {0}", item.LastPostBy));
        }
예제 #8
0
        public string GetStartedBy(object obj)
        {
            TopicInfoDto item = (TopicInfoDto)obj;

            return(string.Format("{0} {1}", TextOfStartedBy, item.IssuedBy));
        }
예제 #9
0
        public bool GetImgVisibility(object obj)
        {
            TopicInfoDto item = (TopicInfoDto)obj;

            return(item.IsSticky);
        }