Example #1
0
        public ArticleType Add(ArticleType articleType)
        {
            using (var context = new PunchClockDbContext())
            {
                articleType.IsDeleted = false;
                context.ArticleTypes.Add(articleType);
                context.ArticleTypeResources.AddRange(articleType.Resources);
                context.SaveChanges();
            }

            return(articleType);
        }
Example #2
0
 public ArticleType Update(ArticleType articleType)
 {
     using (var context = new PunchClockDbContext())
     {
         var existingType = context.ArticleTypes.FirstOrDefault(x => x.Id == articleType.Id);
         if (existingType == null)
         {
             return(articleType);
         }
         existingType.Name         = articleType.Name;
         existingType.Description  = articleType.Description;
         existingType.IsDeleted    = false;
         existingType.ModifiedById = articleType.ModifiedById;
         context.SaveChanges();
     }
     return(articleType);
 }