Beispiel #1
0
        public int Add(DtoArticleParams param)
        {
            Article article = new Article();

            article.CategoryId   = param.CategoryId;
            article.Title        = param.Title;
            article.Body         = param.Body;
            article.Introduction = param.Introduction;
            article.CreatedDate  = DateTime.Now;
            article.Img          = param.Img;
            article.Type         = param.Type;

            dc.Articles.Add(article);

            List <ArticleTag> tags = new List <ArticleTag> ();

            foreach (var item in param.TagIds)
            {
                var articleTag = new ArticleTag();
                articleTag.TagId     = item;
                articleTag.ArticleId = article.Id;
                tags.Add(articleTag);
            }

            dc.ArticleTags.AddRange(tags);
            dc.SaveChanges();

            return(article.Id);
        }
Beispiel #2
0
        public int Add(string email)
        {
            News news = new News();

            news.Email = email;
            dc.News.Add(news);
            dc.SaveChanges();

            return(news.Id);
        }
Beispiel #3
0
        public void Upsert(DtoProfile profile)
        {
            var data = dc.Profile.FirstOrDefault();

            if (data == null)
            {
                data = new Profile();
                dc.Profile.Add(data);
            }

            data.Name        = profile.Name;
            data.Title       = profile.Title;
            data.Description = profile.Description;
            data.Email       = profile.Email;
            data.Facebook    = profile.Facebook;
            data.GitHub      = profile.Github;
            data.Instagram   = profile.Instagram;
            data.LinkEdin    = profile.Linkedin;
            data.Medium      = profile.Medium;

            dc.SaveChanges();
        }
Beispiel #4
0
 public virtual void Save()
 {
     _context.SaveChanges();
 }