Преглед на файлове

Fixed stupid ef relationships...

tags/2.0.3
Teknikode преди 4 години
родител
ревизия
6713696bb5

+ 1
- 1
Teknik/App_Start/BundleConfig.cs Целия файл

@@ -15,7 +15,7 @@ namespace Teknik
bundles.Add(new StyleBundle("~/Content/Common").Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/Content/teknik.css"));
"~/Content/common.css"));

bundles.Add(new ScriptBundle("~/bundles/common").Include(
"~/Scripts/jquery-{version}.js",

+ 3
- 3
Teknik/Areas/Blog/Controllers/BlogController.cs Целия файл

@@ -246,7 +246,7 @@ namespace Teknik.Areas.Blog.Controllers
[AllowAnonymous]
public ActionResult GetComments(int postID, int startCommentID, int count)
{
var comments = db.BlogComments.Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.BlogComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.BlogPostId == postID)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@@ -300,7 +300,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Find(commentID);
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@@ -324,7 +324,7 @@ namespace Teknik.Areas.Blog.Controllers
{
if (ModelState.IsValid)
{
BlogPostComment comment = db.BlogComments.Find(commentID);
BlogPostComment comment = db.BlogComments.Include("User").Where(c => c.BlogPostCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

+ 3
- 3
Teknik/Areas/Blog/Scripts/Blog.js Целия файл

@@ -92,7 +92,7 @@

$('#editComment').on('show.bs.modal', function (e) {
$("#edit_comment_post").val("");
commentID = encodeURIComponent($(e.relatedTarget).attr("id"));
commentID = $(e.relatedTarget).attr("id");
$("#edit_comment_postid").val(commentID);
$.ajax({
type: "POST",
@@ -108,8 +108,8 @@

$("#edit_comment_submit").click(function () {
$('#editComment').modal('hide');
postID = encodeURIComponent($("#edit_comment_postid").val());
post = encodeURIComponent($("#edit_comment_post").val());
postID = $("#edit_comment_postid").val();
post = $("#edit_comment_post").val();
$.ajax({
type: "POST",
url: editCommentURL,

+ 3
- 12
Teknik/Areas/Blog/Views/Blog/Comment.cshtml Целия файл

@@ -1,16 +1,7 @@
@model Teknik.Areas.Blog.ViewModels.CommentViewModel

<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_@Model.CommentId").text();
var new_post = converter.makeHtml(old_post);
$("#title_@Model.CommentId").html(new_post);
// Post Conversion
var old_post = $("#comment_@Model.CommentId").text();
var new_post = converter.makeHtml(old_post);
$("#comment_@Model.CommentId").html(new_post);
</script>
@using Teknik.Helpers

<hr>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
@@ -24,7 +15,7 @@
<button type="button" class="btn btn-danger delete_comment" id="@Model.CommentId">Delete</button>
}
</p>
<p id="comment_@Model.CommentId">@Model.Article</p>
<p id="comment_@Model.CommentId">@Html.Markdown(Model.Article)</p>
</div>
</div>
</div>

+ 1
- 1
Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml Целия файл

@@ -65,7 +65,7 @@
}

<ol class="breadcrumb">
<li><a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = (Model.System) ? string.Empty : Model.Blog.User.Username })">@((Model.System) ? Model.Config.BlogConfig.Title : (string.IsNullOrEmpty(Model.Blog.Title) ? string.Format("{0}'s Blog", Model.Blog.User.Username) : Model.Blog.Title))</a></li>
<li><a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = (Model.System) ? string.Empty : Model.Blog.User.Username })">@((Model.System) ? Model.Config.BlogConfig.Title : (string.IsNullOrEmpty(Model.Blog.User.BlogSettings.Title) ? string.Format("{0}'s Blog", Model.Blog.User.Username) : Model.Blog.User.BlogSettings.Title))</a></li>
<li class="active"><a href="#">@Model.Title</a></li>
</ol>


+ 4
- 4
Teknik/Areas/Podcast/Controllers/PodcastController.cs Целия файл

@@ -305,7 +305,7 @@ namespace Teknik.Areas.Podcast.Controllers
[AllowAnonymous]
public ActionResult GetComments(int podcastId, int startCommentID, int count)
{
var comments = db.PodcastComments.Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
var comments = db.PodcastComments.Include("BlogPost").Include("BlogPost.Blog").Include("BlogPost.Blog.User").Include("User").Where(p => (p.PodcastId == podcastId)).OrderByDescending(p => p.DatePosted).Skip(startCommentID).Take(count).ToList();
List<CommentViewModel> commentViews = new List<CommentViewModel>();
if (comments != null)
{
@@ -321,7 +321,7 @@ namespace Teknik.Areas.Podcast.Controllers
[AllowAnonymous]
public ActionResult GetCommentArticle(int commentID)
{
PodcastComment comment = db.PodcastComments.Where(p => (p.PodcastCommentId == commentID)).First();
PodcastComment comment = db.PodcastComments.Where(p => (p.PodcastCommentId == commentID)).FirstOrDefault();
if (comment != null)
{
return Json(new { result = comment.Article });
@@ -359,7 +359,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Find(commentID);
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))
@@ -383,7 +383,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
if (ModelState.IsValid)
{
PodcastComment comment = db.PodcastComments.Find(commentID);
PodcastComment comment = db.PodcastComments.Include("User").Where(c => c.PodcastCommentId == commentID).FirstOrDefault();
if (comment != null)
{
if (comment.User.Username == User.Identity.Name || User.IsInRole("Admin"))

+ 3
- 3
Teknik/Areas/Podcast/Scripts/Podcast.js Целия файл

@@ -118,7 +118,7 @@

$('#editComment').on('show.bs.modal', function (e) {
$("#edit_comment_post").val("");
commentID = encodeURIComponent($(e.relatedTarget).attr("id"));
commentID = $(e.relatedTarget).attr("id");
$("#edit_comment_id").val(commentID);
$.ajax({
type: "POST",
@@ -134,8 +134,8 @@

$("#edit_comment_submit").click(function () {
$('#editComment').modal('hide');
postID = encodeURIComponent($("#edit_comment_id").val());
post = encodeURIComponent($("#edit_comment_post").val());
postID = $("#edit_comment_id").val();
post = $("#edit_comment_post").val();
$.ajax({
type: "POST",
url: editCommentURL,

+ 3
- 12
Teknik/Areas/Podcast/Views/Podcast/Comment.cshtml Целия файл

@@ -1,16 +1,7 @@
@model Teknik.Areas.Blog.ViewModels.CommentViewModel

<script>
var converter = new Markdown.getSanitizingConverter();
// Title Conversion
var old_post = $("#title_@Model.CommentId").text();
var new_post = converter.makeHtml(old_post);
$("#title_@Model.CommentId").html(new_post);
// Post Conversion
var old_post = $("#comment_@Model.CommentId").text();
var new_post = converter.makeHtml(old_post);
$("#comment_@Model.CommentId").html(new_post);
</script>
@using Teknik.Helpers

<hr>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
@@ -24,7 +15,7 @@
<button type="button" class="btn btn-danger delete_comment" id="@Model.CommentId">Delete</button>
}
</p>
<p id="comment_@Model.CommentId">@Model.Article</p>
<p id="comment_@Model.CommentId">@Html.Markdown(Model.Article)</p>
</div>
</div>
</div>

+ 16
- 2
Teknik/Areas/Profile/Controllers/ProfileController.cs Целия файл

@@ -118,8 +118,8 @@ namespace Teknik.Areas.Profile.Controllers
{
if (ModelState.IsValid)
{
var foundUser = db.Users.Where(b => b.Username == model.Username);
if (foundUser.Any())
var foundUser = db.Users.Where(b => b.Username == model.Username).FirstOrDefault();
if (foundUser != null)
{
return Json(new { error = "That username already exists." });
}
@@ -134,6 +134,9 @@ namespace Teknik.Areas.Profile.Controllers
newUser.JoinDate = DateTime.Now;
newUser.Username = model.Username;
newUser.HashedPassword = SHA384.Hash(model.Username, model.Password);
newUser.UserSettings = new UserSettings();
newUser.BlogSettings = new BlogSettings();
newUser.UploadSettings = new UploadSettings();
db.Users.Add(newUser);
db.SaveChanges();

@@ -201,9 +204,20 @@ namespace Teknik.Areas.Profile.Controllers
{
if (ModelState.IsValid)
{
// Delete Blogs
Blog.Models.Blog blog = db.Blogs.Include("BlogPosts").Include("User").Where(u => u.User.Username == User.Identity.Name).FirstOrDefault();
if (blog != null)
{
db.Blogs.Remove(blog);
db.SaveChanges();
}

User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
if (user != null)
{
user.UserSettings = db.UserSettings.Find(user.UserId);
user.BlogSettings = db.BlogSettings.Find(user.UserId);
user.UploadSettings = db.UploadSettings.Find(user.UserId);
db.Users.Remove(user);
db.SaveChanges();
FormsAuthentication.SignOut();

+ 6
- 0
Teknik/Areas/Profile/Models/BlogSettings.cs Целия файл

@@ -17,6 +17,12 @@ namespace Teknik.Areas.Profile.Models

public string Description { get; set; }

public virtual User User { get; set; }

public virtual UserSettings UserSettings { get; set; }

public virtual UploadSettings UploadSettings { get; set; }

public BlogSettings()
{
Title = string.Empty;

+ 6
- 0
Teknik/Areas/Profile/Models/UploadSettings.cs Целия файл

@@ -17,6 +17,12 @@ namespace Teknik.Areas.Profile.Models

public bool ServerSideEncrypt { get; set; }

public virtual User User { get; set; }

public virtual BlogSettings BlogSettings { get; set; }

public virtual UserSettings UserSettings { get; set; }

public UploadSettings()
{
SaveKey = false;

+ 1
- 5
Teknik/Areas/Profile/Models/User.cs Целия файл

@@ -8,7 +8,6 @@ namespace Teknik.Areas.Profile.Models
{
public class User
{
[Key]
public int UserId { get; set; }
public string Username { get; set; }
@@ -21,13 +20,10 @@ namespace Teknik.Areas.Profile.Models

public List<Group> Groups { get; set; }
[Required]
public virtual UserSettings UserSettings { get; set; }

[Required]
public virtual BlogSettings BlogSettings { get; set; }
[Required]
public virtual UploadSettings UploadSettings { get; set; }

public User()

+ 6
- 0
Teknik/Areas/Profile/Models/UserSettings.cs Целия файл

@@ -19,6 +19,12 @@ namespace Teknik.Areas.Profile.Models

public string Quote { get; set; }

public virtual User User { get; set; }

public virtual BlogSettings BlogSettings { get; set; }

public virtual UploadSettings UploadSettings { get; set; }

public UserSettings()
{
About = string.Empty;

Teknik/Content/teknik.css → Teknik/Content/commono.css Целия файл

@@ -276,3 +276,154 @@ font-size: 24px;
.blockquote-box.blockquote-warning .square{background-color:#F0AD4E;color:#FFF}
.blockquote-box.blockquote-danger{border-color:#D43F3A}
.blockquote-box.blockquote-danger .square{background-color:#D9534F;color:#FFF}


/* column height modifiers */
/* USAGE
<div class="row">
<div class="row-height">
<div class="col-xs-2 col-xs-height col-xs-middle">
<div class="inside"></div>
</div>
<div class="col-xs-4 col-lg-5 col-xs-height col-xs-middle">
<div class="inside"></div>
</div>
</div>
</div>
*/

/* content styles */

.inside {
margin-top: 20px;
margin-bottom: 20px;
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom,color-stop(0%, #f4f4f4), color-stop(100%, #ededed));
background: -moz-linear-gradient(top, #f4f4f4 0%, #ededed 100%);
background: -ms-linear-gradient(top, #f4f4f4 0%, #ededed 100%);
}
.inside-full-height {
/*
// if you want to give content full height give him height: 100%;
// with content full height you can't apply margins to the content
// content full height does not work in ie http://stackoverflow.com/questions/27384433/ie-display-table-cell-child-ignores-height-100
*/
height: 100%;
margin-top: 0;
margin-bottom: 0;
}

/* columns of same height styles */

.row-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-height {
display: table-cell;
float: none;
height: 100%;
}
.col-top {
vertical-align: top;
}
.col-middle {
vertical-align: middle;
}
.col-bottom {
vertical-align: bottom;
}

@media (min-width: 480px) {
.row-xs-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-xs-height {
display: table-cell;
float: none;
height: 100%;
}
.col-xs-top {
vertical-align: top;
}
.col-xs-middle {
vertical-align: middle;
}
.col-xs-bottom {
vertical-align: bottom;
}
}

@media (min-width: 768px) {
.row-sm-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-sm-height {
display: table-cell;
float: none;
height: 100%;
}
.col-sm-top {
vertical-align: top;
}
.col-sm-middle {
vertical-align: middle;
}
.col-sm-bottom {
vertical-align: bottom;
}
}

@media (min-width: 992px) {
.row-md-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-md-height {
display: table-cell;
float: none;
height: 100%;
}
.col-md-top {
vertical-align: top;
}
.col-md-middle {
vertical-align: middle;
}
.col-md-bottom {
vertical-align: bottom;
}
}

@media (min-width: 1200px) {
.row-lg-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-lg-height {
display: table-cell;
float: none;
height: 100%;
}
.col-lg-top {
vertical-align: top;
}
.col-lg-middle {
vertical-align: middle;
}
.col-lg-bottom {
vertical-align: bottom;
}
}

+ 14
- 3
Teknik/Models/TeknikEntities.cs Целия файл

@@ -40,13 +40,24 @@ namespace Teknik.Models
{
modelBuilder.Entity<User>()
.HasRequired(a => a.UserSettings)
.WithRequiredPrincipal();
.WithRequiredPrincipal(a => a.User);
modelBuilder.Entity<User>()
.HasRequired(a => a.BlogSettings)
.WithRequiredPrincipal();
.WithRequiredPrincipal(a => a.User);
modelBuilder.Entity<User>()
.HasRequired(a => a.UploadSettings)
.WithRequiredPrincipal();
.WithRequiredPrincipal(a => a.User);

modelBuilder.Entity<UserSettings>()
.HasRequired(a => a.BlogSettings)
.WithRequiredPrincipal(a => a.UserSettings);
modelBuilder.Entity<UserSettings>()
.HasRequired(a => a.UploadSettings)
.WithRequiredPrincipal(a => a.UserSettings);
modelBuilder.Entity<BlogSettings>()
.HasRequired(a => a.UploadSettings)
.WithRequiredPrincipal(a => a.BlogSettings);

// Users
modelBuilder.Entity<User>().ToTable("Users");

+ 1
- 1
Teknik/Teknik.csproj Целия файл

@@ -351,7 +351,7 @@
<Content Include="Images\logo-blue-io.svg" />
<Content Include="Images\logo-blue.svg" />
<Content Include="Global.asax" />
<Content Include="Content\teknik.css" />
<Content Include="Content\commono.css" />
<Content Include="Images\Icon.png" />
<Content Include="ConnectionStrings.config" />
<Content Include="Areas\Blog\Views\web.config" />

Loading…
Отказ
Запис