public void Save(SpentTime spentTime) { if (spentTime.Id == 0) { _context.SpentTimes.Add(spentTime); } _context.SaveChanges(); }
public void Save(Task task) { if (task.Id == 0) { task.CreatedDate = DateTime.UtcNow; _context.Tasks.Add(task); } _context.SaveChanges(); }
private void AddTestUser() { User = new User() { Email = "*****@*****.**", //Password = "******" }; _dbContext.Users.Add(User); _dbContext.SaveChanges(); }
public void Save(BlogPost blogPost) { if (blogPost.Id == 0 && _context.BlogPosts.WithUrl(blogPost.Url) != null) { throw new DuplicateKeyException(blogPost, "Blog post with the same URL already exists. Please correct blog post title."); } if (blogPost.Id == 0) { _context.BlogPosts.Add(blogPost); } _context.SaveChanges(); }
public void Save(User user) { if (user.Id == 0) { if (Users.WithEmail(user.Email) != null) { throw new DuplicateKeyException(user); } _context.Users.Add(user); } _context.SaveChanges(); }
public void Save(Project project) { if (project.Id == 0) { if (Projects.WithName(project.Name) != null) { throw new DuplicateKeyException(project); } _context.Projects.Add(project); } _context.SaveChanges(); }