public void OnPost() { RelationTypes = RelationTypes ?? string.Empty; try { if (Functions.GetHashString(Password ?? "") != Const.ADMIN_PASSWORD_HASH) { Status = "Incorrect password"; StatusColor = "red"; return; } if (PostName == "" && PostAnnouncement == "" && PostBody == "") { var Id = Convert.ToInt32(PostId); DbInterface.RemovePostById(Id); } var post = new AscSite.Core.Interface.Database.Post { Id = Convert.ToInt32(PostId), Name = PostName, Announcement = PostAnnouncement, Body = PostBody, Type = Convert.ToInt32(PostType) }; if (PostId != "-1") { int postId = Convert.ToInt32(PostId); DbInterface.AddOrUpdatePost(post); DbInterface.DeletePostRelations(postId); var relations = ParseUserRelations(RelationTypes); DbInterface.AddRelations(postId, relations); } else { post.Id = DbInterface.Count() + 1; DbInterface.AddPost(post); var relations = ParseUserRelations(RelationTypes); DbInterface.AddRelations(post.Id, relations); } Status = "Page has been changed successfully"; StatusColor = "green"; } catch (Exception e) { Status = "Error: " + e.Message; StatusColor = "red"; new InternalException(e); } }