Exemplo n.º 1
0
 public static DashboardItem ToDashBoardItem(
     this DataAccess.Article entity)
 {
     return(new DashboardItem
     {
         Url = "/Article/Detail/" + entity.Id,
         Icon = "fa-newspaper-o",
         Name = "Title: " + entity.Name,
         Ordinal = entity.Newsletters.Any()?entity.Newsletters.FirstOrDefault().IssueNo:0,
         Message = entity.CalendarMonth.Name + " " + entity.FinYear.Name,
         DateTimeStamp = entity.PublishDate
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Convert Article Entity  into Article Object
 /// </summary>
 ///<param name="model">ArticleViewModel</param>
 ///<param name="ArticleEntity">DataAccess.Article</param>
 ///<returns>ArticleViewModel</returns>
 public static ArticleQLViewModel ToQueryViewModel(
     this DataAccess.Article entity,
     ArticleQLViewModel model)
 {
     model.Name            = entity.Name;
     model.Author          = entity.Author;
     model.Body            = entity.Body;
     model.Body            = entity.Body;
     model.FinYearId       = entity.FinYearId;
     model.FinYear         = entity.FinYear.Name;
     model.CalendarMonthId = entity.CalendarMonthId;
     model.CalendarMonth   = entity.CalendarMonth.Name;
     model.IssueNo         = entity.Newsletters.Any() ? entity.Newsletters.FirstOrDefault().IssueNo:0;
     return(model);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Convert Article Entity  into Article Object
 /// </summary>
 ///<param name="model">ArticleViewModel</param>
 ///<param name="ArticleEntity">DataAccess.Article</param>
 ///<returns>ArticleViewModel</returns>
 public static ArticleViewModel ToViewModel(
     this DataAccess.Article entity,
     ArticleViewModel model)
 {
     model.Name            = entity.Name;
     model.Author          = entity.Author;
     model.Body            = entity.Body;
     model.Body            = entity.Body;
     model.FinYearId       = entity.FinYearId;
     model.FinYear         = entity.FinYear.Name;
     model.CalendarMonthId = entity.CalendarMonthId;
     model.PublishDate     = entity.PublishDate;
     if (entity.Newsletters.Any())
     {
         model.IssueNo = entity.Newsletters.First().IssueNo;
     }
     return(model);
 }
Exemplo n.º 4
0
        public EditReturnModel InsertArticle(string title, string description, Guid? productId, string content,
                                             bool display, Guid userId)
        {
            try
            {
                var permalink = GeneratePermalink(title);
                var article = new Article()
                    {
                        ArticleId = Guid.NewGuid(),
                        ArticlePermalink = permalink,
                        ArticleDescription = description,
                        ArticleTitle = title,
                        Content = content,
                        CreateBy = userId,
                        CreatedDate = DateTime.UtcNow.AddHours(7),
                        Display = display,
                        ProductId = productId
                    };

                DataContext.Articles.Add(article);

                var result = DataContext.SaveChanges();

                return new EditReturnModel
                    {
                        Result = result > 0
                    };
            }
            catch (Exception exception)
            {
                return new EditReturnModel
                    {
                        Result = false,
                        Message = exception.ToString()
                    };
            }
        }