コード例 #1
0
 private void DeleteAccessTokens(IQueryable <User_Access> userAccesses, DragonflyEntities context)
 {
     if (userAccesses.Count() > 0)
     {
         context.User_Access.RemoveRange(userAccesses);
     }
     try
     {
         context.SaveChanges();
     }
     catch (Exception ex)
     {//TODO log
     }
 }
コード例 #2
0
 private void SaveExistingProjectInDB(Project project, DragonflyEntities context)
 {
     try
     {
         context.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
         context.Project.Remove(project);
         List <ValidationError> validationErrors = ex.RetrieveValidationsErrors();
         throw new InsertDbDataException(validationErrors);
     }
     catch (DbUpdateException ex)
     {
         context.Project.Remove(project);
         throw new InvalidOperationException("Unable to save project", ex);
     }
 }
コード例 #3
0
 private void KeepUserProject(decimal projectId, User_Project usProj, DragonflyEntities context)
 {
     try
     {
         context.User_Project.Add(usProj);
         context.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
         context.User_Project.Remove(usProj);
         List <ValidationError> validationErrors = ex.RetrieveValidationsErrors();
         DeleteProject(projectId);
         throw new InsertDbDataException(validationErrors);
     }
     catch (DbUpdateException ex)
     {
         context.User_Project.Remove(usProj);
         DeleteProject(projectId);
         throw new InvalidOperationException("Unable to save user-project relation", ex);
     }
 }