public bool UpdateArticle(EditArticleViewModel model, IIdentity identity) { if (string.IsNullOrEmpty(model.LID)) { model.LID = model.DisplayTitle; } model.LID = SanitizeLID(model.LID); var article = _repository.Articles.Where(x => x.ArticleID == model.ArticleID).FirstOrDefault(); if (article != null) { IgnoreSupportSameNameTypeInjection <Article> injection = new IgnoreSupportSameNameTypeInjection <Article>( x => x.AddedBy, x => x.AddedDate, x => x.ArticleID ); article.InjectFrom(injection, model); article.UpdatedDate = DateTime.Now; article.UpdatedBy = identity.Name; return(_repository.SaveChanges() == 1); } return(false); }
public bool UpdateComment(EditCommentViewModel model, IIdentity identity) { var comment = _repository.Comments.Where(x => x.CommentID == model.CommentID).FirstOrDefault(); if (comment != null) { IgnoreSupportSameNameTypeInjection <Comment> injection = new IgnoreSupportSameNameTypeInjection <Comment>( x => x.AddedBy, x => x.AddedDate, x => x.CommentID, x => x.ArticleID, x => x.AddedByIP ); comment.InjectFrom(injection, model); comment.UpdatedDate = DateTime.Now; comment.UpdatedBy = identity.Name; } return(_repository.SaveChanges() == 1); }
public bool UpdateFavoriteLink(EditFavoriteLinkViewModel model, IIdentity identity) { var favorite = _repository.FavoriteLinks.Where(x => x.FavoriteLinkID == model.FavoriteLinkID).FirstOrDefault(); if (favorite == null) { return(false); } IgnoreSupportSameNameTypeInjection <FavoriteLink> injection = new IgnoreSupportSameNameTypeInjection <FavoriteLink>( x => x.AddedBy, x => x.AddedDate, x => x.FavoriteLinkID ); favorite.InjectFrom(model); favorite.UpdatedBy = identity.Name; favorite.UpdatedDate = DateTime.Now; return(_repository.SaveChanges() == 1); }
public bool UpdateCategory(EditCategoryViewModel model, IIdentity identity) { var category = _repository.Categories.Where(x => x.CategoryID == model.CategoryID).FirstOrDefault(); if (category != null) { IgnoreSupportSameNameTypeInjection <Category> injection = new IgnoreSupportSameNameTypeInjection <Category>( x => x.AddedBy, x => x.AddedDate, x => x.CategoryID ); category.InjectFrom(injection, model); category.UpdatedDate = DateTime.Now; category.UpdatedBy = identity.Name; if (string.IsNullOrEmpty(category.LID)) { category.LID = category.DisplayTitle; } } return(_repository.SaveChanges() == 1); }