Exemple #1
0
 public bool Add(Article article)
 {
     try
     {
         article.CreateDateTime = _dateAndTime.Get();
         article.ModifyDateTime = _dateAndTime.Get();
         _cmsEntities.Articles.Add(article);
         _cmsEntities.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #2
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool Add(Category category)
 {
     try
     {
         category.CreateDateTime = _dateAndTime.Get();
         category.ModifyDateTime = _dateAndTime.Get();
         _cmsEntities.Categories.Add(category);
         _cmsEntities.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #3
0
        public bool Add(File file)
        {
            try
            {
                var datetimeTW = DateTime.UtcNow.AddHours(8);
                file.CreateDateTime = datetimeTW;
                file.ModifyDateTime = datetimeTW;

                _cmsEntities.Files.Add(file);
                _cmsEntities.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }