public async Task <PostSecurityResult> IsReadAllowedAsync(UserId requester, PostId postId, DateTime timestamp) { requester.AssertNotNull("requester"); postId.AssertNotNull("postId"); if (await this.isPostSubscriber.ExecuteAsync(requester, postId, timestamp)) { return(PostSecurityResult.Subscriber); } if (await this.isPostOwner.ExecuteAsync(requester, postId)) { return(PostSecurityResult.Owner); } if (await this.isPostFreeAccessUser.ExecuteAsync(requester, postId)) { return(PostSecurityResult.GuestList); } if (await this.isFreePostDbStatement.ExecuteAsync(requester, postId)) { return(PostSecurityResult.FreePost); } return(PostSecurityResult.Denied); }
public Task <bool> IsWriteAllowedAsync(UserId requester, PostId postId) { requester.AssertNotNull("requester"); postId.AssertNotNull("postId"); return(this.isPostOwner.ExecuteAsync(requester, postId)); }
protected override void LoadContent(GraffitiContext graffitiContext) { graffitiContext["where"] = "post"; Post post = Post.GetCachedPost(PostId); if (post.IsDeleted || (!post.IsPublished && GraffitiUsers.Current == null)) { RedirectTo(new Urls().Home); } else if (PostName != null && CategoryName != null && (!Util.AreEqualIgnoreCase(PostName, post.Name) || !Util.AreEqualIgnoreCase(CategoryName, post.Category.LinkName))) { RedirectTo(post.Url); } else if (Context.Request.Cookies["Graffiti-Post-" + PostId] == null) { Post.UpdateViewCount(PostId); //SPs.UpdatePostView(PostId).Execute(); HttpCookie cookie = new HttpCookie("Graffiti-Post-" + PostId, PostId.ToString()); Context.Response.Cookies.Add(cookie); } graffitiContext["title"] = post.Title + " : " + SiteSettings.Get().Title; graffitiContext["category"] = post.Category; graffitiContext["post"] = post; graffitiContext.RegisterOnRequestDelegate("feedback", GetPostFeedback); graffitiContext.RegisterOnRequestDelegate("comments", GetPostComments); graffitiContext.RegisterOnRequestDelegate("trackbacks", GetPostTrackbacks); }
public static (BlogPost post, ArgumentException error) Create(PostId blogId, string category, string title, string content) { var errorMessage = string.Empty; if (blogId.Value == Guid.Empty) { errorMessage += $"{nameof(blogId)}"; } if (string.IsNullOrEmpty(category)) { errorMessage += $"{nameof(category)}"; } if (string.IsNullOrEmpty(title)) { errorMessage += $"{nameof(category)}"; } if (string.IsNullOrEmpty(content)) { errorMessage += $"{nameof(category)}"; } if (!string.IsNullOrEmpty(errorMessage)) { return(null, new ArgumentException($"Key data: ${errorMessage}, cannot be empty.")); } return(new BlogPost(blogId, category, title, content, DateTime.Now), null); }
private void WriteWorkers(IEnumerable <Worker> collection, XmlWriter writer) { writer.WriteStartElement("WorkersData"); foreach (var inst in collection) { writer.WriteStartElement("Worker"); writer.WriteElementString("Id", inst.Id.ToString()); writer.WriteElementString("Name", inst.Name); int PostId; if (inst.Post == null) { PostId = 0; } else { PostId = inst.Post.Id; } writer.WriteElementString("PostId", PostId.ToString()); writer.WriteElementString("Unit", inst.Unit); writer.WriteElementString("Exp", inst.Exp.ToString()); writer.WriteElementString("Bio", inst.Bio); writer.WriteElementString("Kharakteristika", inst.Kharakteristika); writer.WriteEndElement(); } writer.WriteEndElement(); }
public RegisterView getHabit([FromBody] PostId data) { UserHabit userHabit = _userservice.GetUserHabit(data.account); RegisterView nowUser = Mapper.Map <RegisterView>(userHabit); return(nowUser); }
public ProfileView getProfile(PostId account) { User nowUser = _userservice.Get(account.account); ProfileView profileUser = Mapper.Map <ProfileView>(nowUser); return(profileUser); }
public async Task ExecuteAsync(PostId postId, QueueId queueId) { postId.AssertNotNull("postId"); queueId.AssertNotNull("queueId"); var nextLiveDate = await this.getLiveDateOfNewQueuedPost.ExecuteAsync(queueId); var post = new Post(postId.Value) { QueueId = queueId.Value, LiveDate = nextLiveDate }; var parameters = new SqlGenerationParameters <Post, Post.Fields>(post) { UpdateMask = Post.Fields.QueueId | Post.Fields.LiveDate, Conditions = new[] { WherePostLiveDateUniqueToQueue, // Perform locks in 'descending supersets' to avoid deadlock. WherePostNotInQueue } }; using (var connection = this.connectionFactory.CreateConnection()) { var failedConditionIndex = await connection.UpdateAsync(parameters); var concurrencyFailure = failedConditionIndex == 0; if (concurrencyFailure) { throw new OptimisticConcurrencyException(string.Format("Failed to optimistically queue post with queue {0}", queueId)); } } }
public IEnumerable <SavedEntry> Get(int count) { List <SavedEntry> result = new List <SavedEntry>(); using (var connection = this.MemoryConnection()) { connection.Open(); using (var transaction = connection.BeginTransaction()) using (var command = connection.CreateCommand()) { command.CommandText = "SELECT" + "post_id, name, message, timestamp, ip_address" + "FROM entry ORDER BY post_id DESC"; try { using (var reader = command.ExecuteReader()) { while (reader.Read()) { var postId = new PostId((int)reader["post_id"]); var name = new Name((string)reader["name"]); var message = new Message((string)reader["message"]); var timestamp = Timestamp.FromUnixTime((double)reader["timestamp"]); var ipAddress = IPAddress.FromString((string)reader["ip_address"]); result.Add(new SavedEntry(postId, name, message, timestamp, ipAddress)); } } } catch (Exception) { } } } return(result); }
public async Task PostPost([FromBody] NewPostData postData) { postData.AssertBodyProvided("postData"); var post = postData.Parse(); var requester = await this.requesterContext.GetRequesterAsync(); var newPostId = new PostId(this.guidCreator.CreateSqlSequential()); var timestamp = this.timestampCreator.Now(); await this.postPost.HandleAsync(new PostToChannelCommand( requester, newPostId, post.ChannelId, post.PreviewImageId, post.PreviewText, post.Content, post.PreviewWordCount, post.WordCount, post.ImageCount, post.FileCount, post.VideoCount, post.FileIds ?? new List <FileId>(), post.ScheduledPostTime, post.QueueId, timestamp)); }
private async Task CreatePostAsync(UserId newUserId, PostId newPostId, TestDatabaseContext testDatabase) { using (var databaseContext = testDatabase.CreateContext()) { await databaseContext.CreateTestNoteAsync(newUserId.Value, newPostId.Value); } }
public async Task ExecuteAsync(PostId postId, DateTime now, Func <Task> potentialRemovalOperation) { postId.AssertNotNull("postId"); now.AssertUtc("now"); potentialRemovalOperation.AssertNotNull("potentialRemovalOperation"); var queuedCollectionId = await this.tryGetPostQueueId.ExecuteAsync(postId, now); if (queuedCollectionId == null) { await potentialRemovalOperation(); } else { var weeklyReleaseSchedule = await this.getWeeklyReleaseSchedule.ExecuteAsync(queuedCollectionId); using (var transaction = TransactionScopeBuilder.CreateAsync()) { await potentialRemovalOperation(); await this.defragmentQueue.ExecuteAsync(queuedCollectionId, weeklyReleaseSchedule, now); transaction.Complete(); } } }
public override int GetHashCode() { unchecked { return((TagId.GetHashCode() * 397) ^ PostId.GetHashCode()); } }
public override int GetHashCode() { int hash = 1; if (PostId != 0) { hash ^= PostId.GetHashCode(); } if (Description.Length != 0) { hash ^= Description.GetHashCode(); } if (Domain.Length != 0) { hash ^= Domain.GetHashCode(); } if (date_ != null) { hash ^= Date.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public object SubmitCert(PostId cert) { if (cert == null || string.IsNullOrEmpty(cert.Id)) { return(new ReturnResult <bool>(-4, "传入参数错误!")); } return(_UsersService.SubmitCert(cert.Id)); }
/// <summary> /// 删除用户信息(暂时不提供调用) /// </summary> /// <param name="id">用户ID</param> //[Route("DeleteUser")] //[HttpDelete] public object DeleteUser(PostId user) { if (user == null || string.IsNullOrEmpty(user.Id)) { return(new ReturnResult <bool>(-4, "传入参数错误!")); } return(_UsersService.DeleteUser(user.Id)); }
public async Task DeletePost(string postId) { postId.AssertUrlParameterProvided("postId"); var parsedPostId = new PostId(postId.DecodeGuid()); var requester = await this.requesterContext.GetRequesterAsync(); await this.deletePost.HandleAsync(new DeletePostCommand(parsedPostId, requester)); }
public object DeleteAnswer(PostId answer) { if (answer == null || string.IsNullOrEmpty(answer.Id)) { return(new ReturnResult <bool>(-4, "传入参数错误!")); } return(_QuestionService.DeleteAnswer(answer.Id)); }
public object SubmitProduct(PostId pro) { if (pro == null || string.IsNullOrEmpty(pro.Id)) { return(new ReturnResult <bool>(-4, "参数传入错误!")); } return(_ProductService.SubmitProduct(pro.Id)); }
public object DeleteProduct(PostId product) { if (product == null || string.IsNullOrEmpty(product.Id)) { return(new ReturnResult <bool>(-4, "参数传入错误!")); } return(_ProductService.DeleteProduct(product.Id)); }
public object DeleteDictionary(PostId dic) { if (dic == null || string.IsNullOrEmpty(dic.Id)) { return(new ReturnResult <bool>(-4, "传入参数错误!")); } return(_SystemService.DeleteDictionary(dic.Id)); }
public object DeleteQuestion(PostId question) { if (question == null || string.IsNullOrEmpty(question.Id)) { return(new ReturnResult <bool>(-2, "参数传入错误")); } return(_QuestionService.DeleteQuestion(question.Id)); }
public async Task PostToLive([FromBody] string postId) { postId.AssertBodyProvided("postId"); var parsedPostId = new PostId(postId.DecodeGuid()); var requester = await this.requesterContext.GetRequesterAsync(); await this.rescheduleForNow.HandleAsync(new RescheduleForNowCommand(requester, parsedPostId)); }
public object AuditNotice(PostId notice) { if (notice == null || string.IsNullOrEmpty(notice.Id)) { return(new ReturnResult <bool>(-4, "传入参数错误!")); } return(_NoticeService.AuditNotice(notice.Id)); }
public object UpdateCommentCount(PostId question) { if (question == null || string.IsNullOrEmpty(question.Id)) { return(new ReturnResult <QuestionModel>(-4, "传入参数错误!")); } return(_QuestionService.UpdateCommentCount(question.Id)); }
public object SubmitDemand(PostId demand) { if (demand == null || string.IsNullOrEmpty(demand.Id)) { return(new ReturnResult <bool>(-4, "参数传入错误!")); } return(_DemandService.SubmitDemand(demand.Id)); }
public object AuditPassQuestion(PostId question) { if (question == null || string.IsNullOrEmpty(question.Id)) { return(new ReturnResult <QuestionModel>(-4, "传入参数错误!")); } return(_QuestionService.AuditQuestion(question.Id)); }
private async Task <PostResponse> Post() { return(JsonSerializerExtension.Serializer.DeserializeFromStream <PostResponse>(await(await MyHttpClient.PostAsync( PostUrl, new FormUrlEncodedContent( new Dictionary <string, string> { { "id", PostId.ToString() } }))).Content.ReadAsStreamAsync())); }
public object UpdateHeatCount(PostId question) { if (question == null || string.IsNullOrEmpty(question.Id)) { return(new ReturnResult <QuestionModel>(-4, "传入参数错误!")); } _QuestionService.UpdateHeatCount(question.Id); return(new ReturnResult <bool>(1, true)); }
private Task RescheduleForNowAsync(PostId postId) { var now = this.timestampCreator.Now(); return(this.defragmentQueueIfRequired.ExecuteAsync( postId, now, () => this.setPostLiveDate.ExecuteAsync(postId, now, now))); }