public void Delete(DalUsersTest e)
        {
            if (context.Database.Connection.State != ConnectionState.Open)
            {
                context.Database.Connection.Open();
            }
            UsersTests ut = context.Set <UsersTests>().
                            FirstOrDefault(a => a.id == e.Id);

            context.Set <UsersTests>().Remove(ut);
        }
 public static UsersTestsEntity ToBllUsersTest(this DalUsersTest e)
 {
     return(new UsersTestsEntity()
     {
         Id = e.Id,
         BeginningTime = e.BeginningTime,
         EndingTime = e.EndingTime,
         MarkForTest = e.MarkForTest,
         RightAnswersCount = e.RightAnswersCount,
         TestId = e.TestId,
         UserId = e.UserId
     });
 }
        public void Update(DalUsersTest entity)
        {
            if (context.Database.Connection.State != ConnectionState.Open)
            {
                context.Database.Connection.Open();
            }
            UsersTests ut = context.Set <UsersTests>().
                            FirstOrDefault(a => a.id == entity.Id);

            ut.BeginningTime     = entity.BeginningTime;
            ut.EndingTime        = entity.EndingTime;
            ut.MarkForTest       = entity.MarkForTest;
            ut.RightAnswersCount = entity.RightAnswersCount;
            ut.TestId            = entity.TestId;
            ut.UserId            = entity.UserId;
        }
        public void Create(DalUsersTest e)
        {
            if (context.Database.Connection.State != ConnectionState.Open)
            {
                context.Database.Connection.Open();
            }
            UsersTests ut = new UsersTests()
            {
                id                = e.Id,
                BeginningTime     = e.BeginningTime,
                EndingTime        = e.EndingTime,
                MarkForTest       = e.MarkForTest,
                RightAnswersCount = e.RightAnswersCount,
                TestId            = e.TestId,
                UserId            = e.UserId
            };

            context.Set <UsersTests>().Add(ut);
        }
Ejemplo n.º 5
0
        public IEnumerable <DalUsersAnswers> GetByUsersTest(DalUsersTest usersTest)
        {
            if (context.Database.Connection.State != ConnectionState.Open)
            {
                context.Database.Connection.Open();
            }
            IEnumerable <UsersAnswers> ua = context.Set <UsersAnswers>().
                                            Where(a => a.UsersTestId == usersTest.Id);
            List <DalUsersAnswers> result = new List <DalUsersAnswers>();

            foreach (UsersAnswers u in ua)
            {
                result.Add(new DalUsersAnswers()
                {
                    AnswerStructure = u.AnswerStructure,
                    BeginningTime   = u.BeginningTime,
                    EndingTime      = u.EndingTime,
                    QuestionId      = u.QuestionId,
                    UserTestId      = u.UsersTestId
                });
            }
            return(result);
        }