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)); }
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); }
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); } } }
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); } }
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); }
public string GetLastPostTime(object obj) { TopicInfoDto item = (TopicInfoDto)obj; return(item.LastPostTime.ToString(WebContext.Current.ApplicationOption.DateTimeFormat)); }
public string GetLastPostBy(object obj) { TopicInfoDto item = (TopicInfoDto)obj; return(string.Format("by {0}", item.LastPostBy)); }
public string GetStartedBy(object obj) { TopicInfoDto item = (TopicInfoDto)obj; return(string.Format("{0} {1}", TextOfStartedBy, item.IssuedBy)); }
public bool GetImgVisibility(object obj) { TopicInfoDto item = (TopicInfoDto)obj; return(item.IsSticky); }