public async Task <IHttpActionResult> CheckProjectExist(IEnumerable <ProjectExistCheckModel> checkModel) { IQueryable <Project> query = _db.GetProjects(User.Identity.GetUserId()); ExpressionStarter <Project> predicate = PredicateBuilder.New <Project>(false); predicate = checkModel.Aggregate( predicate, (current, cm) => current.Or(p => p.FileSize == cm.FileSize && p.FileName == cm.FileName && p.Name == cm.Name)); var exists = await query.AnyAsync(predicate); return(Ok(new { isAllUnique = !exists })); }
//////////////////////////////////////////////////////////// // Private Methods/Atributes //////////////////////////////////////////////////////////// private bool AllProjectsExist(int[] projectId) { var foundProjects = _db.GetProjects(User.Identity.GetUserId()) .Count(p => p.IsReady && !p.Failed && projectId.Contains(p.Id)); return(foundProjects == projectId.Length); }
private IQueryable <Project> GetProjects() { return(_db.GetProjects(User.Identity.GetUserId())); }