public new void Update(Task task) { if (Dbset.Any(x => x.Id != task.Id && x.UserId == task.UserId && x.Title.Equals(task.Title, StringComparison.OrdinalIgnoreCase) && x.ShortTitle.Equals(task.ShortTitle, StringComparison.OrdinalIgnoreCase) && x.Theme == task.Theme)) { throw new MyException("You already have a Task with the same Title, Short Title and Theme."); } _context.Entry(task).State = EntityState.Modified; _context.SaveChanges(); }
public override void Create(Task task) { if (Dbset.Any(x => x.Id != task.Id && x.UserId == task.UserId && x.Title.Equals(task.Title, StringComparison.OrdinalIgnoreCase) && x.ShortTitle.Equals(task.ShortTitle, StringComparison.OrdinalIgnoreCase) && x.Theme == task.Theme)) { throw new MyException("You already have a Task with the same Title, Short Title and Theme."); } task.Order = Convert.ToInt16(Dbset.Count(x => x.UserId == task.UserId && x.IsArchived == false) + 1); Dbset.Add(task); _context.SaveChanges(); }
public bool CreateTeam(string teamName) { if (!Dbset.Any(a => a.Name.ToLower() == teamName.ToLower())) { Add(new Team { CreateDate = DateTime.Now, Name = teamName }); return(true); } return(false); }