Esempio n. 1
0
        internal static List <TextModel> GetTextList()
        {
            List <TextModel> _list = null;

            using (var context = new ExamProjectDbEntities())
            {
                _list = (from Text in context.Text
                         select new TextModel()
                {
                    Text_ID = Text.Text_ID,
                    Context = Text.Context
                }).ToList();
            }
            return(_list);
        }
Esempio n. 2
0
        internal static string DeleteUser(string id)
        {
            string _email;

            using (var context = new ExamProjectDbEntities())
            {
                var _user = context.AspNetUsers.Where(u => u.Id == id).FirstOrDefault();
                _email = _user.Email;
                var _exUser = context.AspNetUserExtended.Where(u => u.Id == id).FirstOrDefault();
                context.Entry(_user).State   = System.Data.Entity.EntityState.Deleted;
                context.Entry(_exUser).State = System.Data.Entity.EntityState.Deleted;
                context.SaveChanges();
            }
            return(_email);
        }
Esempio n. 3
0
 internal static bool SonucuKontrolEt(int id, string cevap)
 {
     using (var context = new ExamProjectDbEntities())
     {
         Question _question = context.Question.Where(x => x.QId == id).FirstOrDefault();
         if (_question.Answer == cevap)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 4
0
 internal void Create(string userId)
 {
     using (var context = new ExamProjectDbEntities())
     {
         AspNetUserExtended _ext = new AspNetUserExtended()
         {
             Id       = userId,
             Name     = Name,
             SurName  = Surname,
             UserType = UserType,
         };
         context.Entry(_ext).State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 internal void Create(int textId)
 {
     using (var context = new ExamProjectDbEntities())
     {
         ExamProject.Database.Question _question = new Question()
         {
             Option_A = Option_A,
             Option_B = Option_B,
             Option_C = Option_C,
             Option_D = Option_D,
             Text_ID  = textId,
             Soru     = Soru,
             Answer   = Answer,
         };
         context.Entry(_question).State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();
     }
 }
Esempio n. 6
0
        internal static List <AspNetUserExtendedModel> GetList()
        {
            List <AspNetUserExtendedModel> _list = null;

            using (var context = new ExamProjectDbEntities())
            {
                _list = (from UserExtended in context.AspNetUserExtended
                         join RoleExtended in context.AspNetRoles on UserExtended.UserType equals RoleExtended.Id
                         join User in context.AspNetUsers on UserExtended.Id equals User.Id
                         select new AspNetUserExtendedModel()
                {
                    UserRole = RoleExtended.Name,
                    Email = User.Email,
                    EmailConfirmed = User.EmailConfirmed,
                    UserType = RoleExtended.Id,
                    Id = UserExtended.Id,
                    Name = UserExtended.Name,
                    Surname = UserExtended.SurName,
                }).ToList();
            }
            return(_list);
        }
Esempio n. 7
0
        internal static AspNetUserExtendedModel LoadModel(string userId)
        {
            AspNetUserExtendedModel _model;

            using (var context = new ExamProjectDbEntities())
            {
                //_model = context.AspNetUsersExtended.Where(x => x.Id.Equals(userId))
                //    .Select(u => new AspNetUsersExtendedModel()
                //    {
                //        Id = u.Id,
                //        Name = u.Name,
                //        Surname = u.Surname,

                //    })
                //    .FirstOrDefault();
                _model = (from UserExtended in context.AspNetUserExtended
                          .Where(x => x.Id == userId).DefaultIfEmpty()
                          from RoleExtended in context.AspNetRoles
                          .Where(x => x.Id == UserExtended.UserType).DefaultIfEmpty()
                          select new AspNetUserExtendedModel
                {
                    UserRole = RoleExtended.Name,
                    Id = UserExtended.Id,
                    Name = UserExtended.Name,
                    Surname = UserExtended.SurName,
                    UserType = UserExtended.UserType,
                }).FirstOrDefault();

                //var _type = (from UserExtended in context.AspNetUsersExtended.Where(x => x.Id.Equals(userId))
                //             join RoleExtended in context.AspNetRoles on UserExtended.UserType equals RoleExtended.Id select RoleExtended).FirstOrDefault();


                var _usr = context.AspNetUsers.Where(x => x.Id.Equals(userId)).FirstOrDefault();
                _model.Email          = _usr.Email;
                _model.EmailConfirmed = _usr.EmailConfirmed;
            }

            return(_model);
        }
Esempio n. 8
0
        internal static List <SinavModel> GetTextQuestions(int Text_Id)
        {
            List <SinavModel> _questionList = null;

            using (var context = new ExamProjectDbEntities())
            {
                _questionList = (from Quextion in context.Question
                                 join Text in context.Text on Quextion.Text_ID equals Text.Text_ID
                                 where Quextion.Text_ID == Text_Id
                                 select new SinavModel()
                {
                    QId = Quextion.QId,
                    Text = Text.Context,
                    Soru = Quextion.Soru,
                    Option_A = Quextion.Option_A,
                    Option_B = Quextion.Option_B,
                    Option_C = Quextion.Option_C,
                    Option_D = Quextion.Option_D,
                    Answer = Quextion.Answer,
                }).ToList();
            }
            return(_questionList);
        }