public void Delete(T entity) { MBTIEntities context = CreateContext(); context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); }
public void Update(T entity) { MBTIEntities context = CreateContext(); context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); }
public void Insert(T entity) { MBTIEntities context = CreateContext(); context.Entry(entity).State = EntityState.Added; context.SaveChanges(); }
protected MBTIEntities CreateContext() { MBTIEntities context = new MBTIEntities(); context.Configuration.ProxyCreationEnabled = false; context.Database.Log = x => Console.WriteLine(x); return(context); }
public List <Response> Get(int testId, int questionNumber) { MBTIEntities context = CreateContext(); var query = from x in context.Responses where x.TestId == testId && (x.QuestionId == questionNumber.ToString() + "a" || x.QuestionId == questionNumber.ToString() + "b") select x; return(query.ToList()); }
public List <Response> Get(int testId) { MBTIEntities context = CreateContext(); var query = from x in context.Responses where x.TestId == testId select x; return(query.ToList()); }
public User Get(string name, string email) { MBTIEntities context = CreateContext(); return(context.Users.FirstOrDefault(x => x.Name == name && x.Email == email)); }
public User Get(int userId) { MBTIEntities context = CreateContext(); return(context.Users.FirstOrDefault(x => x.UserId == userId)); }
public Question Get(string questionId) { MBTIEntities context = CreateContext(); return(context.Questions.FirstOrDefault(x => x.Id == questionId)); }
public int GetCount() { MBTIEntities context = CreateContext(); return(context.Set <T>().Count()); }
public List <T> GetAll() { MBTIEntities context = CreateContext(); return(context.Set <T>().ToList()); }
public PersonalityType Get(int PersonalityId) { MBTIEntities context = CreateContext(); return(context.PersonalityTypes.FirstOrDefault(x => x.Id == PersonalityId)); }
public Test Get(int testId) { MBTIEntities context = CreateContext(); return(context.Tests.FirstOrDefault(x => x.TestId == testId)); }