Exemplo n.º 1
0
        public static List <School> GetSinavOturumOkullari(int SinavOturumId)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var sinavokullar = db.SinavOturum.Include("Okullar").FirstOrDefault(d => d.SinavOturumId == SinavOturumId);
                    var okulListesi  = new List <School>();

                    okulListesi.AddRange(sinavokullar.Okullar);
                    foreach (var item in okulListesi)
                    {
                        var oturumokulu = SinavManager.GetSinavOturumOkulu(item.SchoolId, SinavOturumId);
                        if (oturumokulu == null)
                        {
                            item.SalonSayisi = 0;
                        }
                        else
                        {
                            item.SalonSayisi = oturumokulu.SalonSayisi;
                        }
                    }

                    return(okulListesi.OrderBy(d => d.MebKodu).ToList());
                }
                catch (Exception)
                {
                    return(null);
                }
            }
        }
Exemplo n.º 2
0
        public static Result add(School school)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var repo   = new Repository <School>(db);
                    var sch    = repo.Find(d => d.Ad == school.Ad && d.IsDeleted == false);
                    var schmeb = repo.Find(d => d.MebKodu == school.MebKodu && d.IsDeleted == false);

                    if (sch.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniOkulSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return(result);
                    }
                    else if (schmeb.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniMebKoduSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return(result);
                    }
                    repo.Add(school);
                    result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                    return(result);
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return(result);
                }
            }
        }
Exemplo n.º 3
0
        public static bool SinavBasvur(int SinavOturumId, int TeacherId)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    SinavBasvuru basvuru = db.SinavBasvuru.FirstOrDefault(d => d.SinavOturumId == SinavOturumId && d.TeacherId == TeacherId);

                    if (basvuru == null)
                    {
                        SinavBasvuru slist = new SinavBasvuru();
                        slist.SinavOturumId = SinavOturumId;
                        slist.TeacherId     = TeacherId;
                        db.SinavBasvuru.Add(slist);
                        db.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 4
0
        public static List <Teacher> GetTeacherListForOzelBasvuru(int SinavOturumId)
        {
            using (SGContext db = new SGContext())
            {
                var listo = db.Teacher.Include("SinavBasvuru")
                            .Include("User")
                            .Include("Okul")
                            .Where(d => d.SinavBasvuru.FirstOrDefault(f => f.SinavOturumId == SinavOturumId && f.TeacherId == d.TeacherId).SinavOturumId == SinavOturumId)
                            .ToList();



                var temp = db.SinavGorevli.Where(d => d.SinavOturumId == SinavOturumId && d.SinavGorevId == (int)SG_DAL.Enums.EnumSinavGorev.Gozetmen);

                if (temp.Count() > listo.Count())
                {
                    List <Teacher> tchList = new List <Teacher>();

                    foreach (var item in temp)
                    {
                        Teacher tcm = TeacherManager.GetTeacher(item.TeacherId);
                        tchList.Add(tcm);
                    }

                    return(tchList);
                }

                return(listo);
            }
        }
Exemplo n.º 5
0
 private static string GetKomisyonUyesi(int SinavOturumId, int okulID, int uyeSira)
 {
     using (SGContext db = new SGContext())
     {
         try
         {
             if (uyeSira == 1)
             {
                 var gorevli = db.SinavGorevli.First(d => d.SinavOturumId == SinavOturumId && d.SchoolId == okulID && d.SinavGorevId == (int)SG_DAL.Enums.EnumSinavGorev.BinaSinavKomisyonuUyesi);
                 var tch     = db.Teacher.Include("User").First(d => d.TeacherId == gorevli.TeacherId);
                 return(tch.User.Ad + " " + tch.User.Soyad);
             }
             else
             {
                 var gorevli = db.SinavGorevli.Last(d => d.SinavOturumId == SinavOturumId && d.SchoolId == okulID && d.SinavGorevId == (int)SG_DAL.Enums.EnumSinavGorev.BinaSinavKomisyonuUyesi);
                 var tch     = db.Teacher.Include("User").First(d => d.TeacherId == gorevli.TeacherId);
                 return(tch.User.Ad + " " + tch.User.Soyad);
             }
         }
         catch (Exception)
         {
             return(null);
         }
     }
 }
Exemplo n.º 6
0
        public static Result CreateUser(User newUser)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var userRepository = new Repository <User>(db);
                    var user           = userRepository.Find(d => d.TCKimlik == newUser.TCKimlik);

                    if (user.Count() < 1)
                    {
                        if (string.IsNullOrEmpty(newUser.Sifre))
                        {
                            newUser.Sifre = newUser.TCKimlik.ToString();
                        }

                        userRepository.Add(newUser);
                        result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                        return(result);
                    }
                    else
                    {
                        result = new Result(SystemRess.Messages.hata_ayniTcSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return(result);
                    }
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return(result);
                }
            }
        }
Exemplo n.º 7
0
        public static Result updateTeacher(User newUser, Teacher teacher)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var userRepository = new Repository <User>(db);
                    var tchRepo        = new Repository <Teacher>(db);
                    var user           = userRepository.First(d => d.UserId == newUser.UserId);
                    var tch            = tchRepo.First(d => d.TeacherId == teacher.TeacherId);

                    user.Ad       = newUser.Ad;
                    user.Email    = newUser.Email;
                    user.Soyad    = newUser.Soyad;
                    user.TCKimlik = newUser.TCKimlik;
                    user.Tel      = newUser.Tel;

                    tch.GenelBasvuru = teacher.GenelBasvuru;
                    tch.Kidem        = teacher.Kidem;
                    tch.SchoolId     = teacher.SchoolId;
                    tch.Unvan        = teacher.Unvan;

                    db.SaveChanges();

                    result = new Result(SystemRess.Messages.basarili_kayit.ToString(), SystemRess.Messages.basarili_durum.ToString());
                    return(result);
                }
                catch (Exception)
                {
                    result = new Result(SystemRess.Messages.hatali_kayit.ToString(), SystemRess.Messages.hatali_durum.ToString());
                    return(result);
                }
            }
        }
Exemplo n.º 8
0
        public static User Login(Int64 tckimlikno, string password)
        {
            using (SGContext db = new SGContext())
            {
                var userRepository = new Repository <User>(db);
                var us             = userRepository.Find(d => d.TCKimlik == tckimlikno && d.Sifre == password);

                if (us.Count() > 0)
                {
                    User record = new User();
                    SG_DAL.Enums.EnumRol rol = (SG_DAL.Enums.EnumRol)(us.FirstOrDefault().Rol);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, us.FirstOrDefault().Ad + " " + us.FirstOrDefault().Soyad, DateTime.Now, DateTime.Now.AddMinutes(120), false, rol.ToString(), FormsAuthentication.FormsCookiePath);
                    string     encTicket             = FormsAuthentication.Encrypt(ticket);
                    HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                    if (ticket.IsPersistent)
                    {
                        cookie.Expires = ticket.Expiration;
                    }
                    HttpContext.Current.Response.Cookies.Add(cookie);

                    HttpCookie myCookie = new HttpCookie("LoginCookie");
                    myCookie["tcno"] = us.FirstOrDefault().TCKimlik.ToString();
                    myCookie.Expires = DateTime.Now.AddDays(1d);
                    HttpContext.Current.Response.Cookies.Add(myCookie);

                    return(us.FirstOrDefault());
                }
                else
                {
                    return(null);
                }
            }
        }
Exemplo n.º 9
0
        public static List <rptOgretmenListe> GetTeacherListForReport()
        {
            using (SGContext db = new SGContext())
            {
                var list = (from ogtLer in db.Teacher
                            join o in db.User on ogtLer.User.UserId equals o.UserId
                            where ogtLer.IsDeleted == false
                            select new
                {
                    Ad = o.Ad,
                    Soyad = o.Soyad,
                    TCKimlik = o.TCKimlik,
                    Email = o.Email,
                    Tel = o.Tel,
                    Kidem = ogtLer.Kidem,
                    Unvan = ogtLer.Unvan
                }).ToList();

                List <rptOgretmenListe> ogtler = new List <rptOgretmenListe>();

                foreach (var item in list)
                {
                    rptOgretmenListe ogt = new rptOgretmenListe(item.Ad, item.Soyad, item.TCKimlik, item.Email, item.Tel, item.Kidem, item.Unvan);
                    ogtler.Add(ogt);
                }
                return(ogtler);
            }
        }
Exemplo n.º 10
0
        public static List <SinavOturum> GetOgretmenBasvurulari(int TeacherId)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var oturumlar = SinavListe((int)SG_DAL.Enums.EnumSinavDurum.OnaylanmisSinav);

                    var basvurular = db.SinavBasvuru.Where(d => d.TeacherId == TeacherId);

                    List <SinavOturum> basvuruoturum = new List <SinavOturum>();

                    foreach (var bsv in basvurular)
                    {
                        foreach (var otrm in oturumlar)
                        {
                            if (bsv.SinavOturumId == otrm.SinavOturumId)
                            {
                                basvuruoturum.Add(otrm);
                            }
                        }
                    }

                    return(basvuruoturum.Distinct().ToList());
                }
                catch
                {
                    return(new List <SinavOturum>().ToList());
                }
            }
        }
Exemplo n.º 11
0
        public void TestBasicAddRemoveUser()
        {
            IConfiguration config = getTestConfiguration();

            using (var context = new SGContext(config))
            {
                var adminTask = LoginTokenTasks.LoginAsync(context, Defaults.UserAdmin, Defaults.UserAdminPassword);
                adminTask.Wait();
                var admin = adminTask.Result;

                var userA = TryCreateUser(context, admin, "user@localhost", "pwd");
                Assert.IsNotNull(userA, "Failed to create a valid user user@localhost");
                var userB = TryCreateUser(context, admin, "user@localhost", "pwd");
                Assert.IsNull(userB, "Incorrectly succeeded in creating a user that already exists.");

                var userC = TryCreateUser(context, admin, "user2@localhost", "pwd");
                Assert.IsNotNull(userA, "Failed to create a valid user user2@localhost");

                TryChangeUserDisplayEmailAndName(context, admin, userA, "userA@localhost", "User A new name");

                var userTask = UserTasks.QuickGetUserNoAuthCheckAsync(context, "userA@localhost");
                userTask.Wait();
                var userA_2 = userTask.Result;

                Assert.IsNotNull(userA_2, "User failed to be retrieved after email update");
                Assert.AreEqual(userA_2.Id, userA.Id, "User that came back after email change had a different ID.");
                Assert.AreEqual(userA_2.DisplayName, "User A new name", "Displayname update failed.");
            }
        }
Exemplo n.º 12
0
        public void TestBasicLogin()
        {
            IConfiguration config = getTestConfiguration();

            using (var context = new SGContext(config))
            {
                var tokenTask = LoginTokenTasks.LoginAsync(context, "admin@localhost", "password");
                tokenTask.Wait();
                var token = tokenTask.Result;
                Assert.IsTrue(token != null, "Login token returned null");
                Assert.IsFalse(token.UserId == 0, "I've broken the EF key link somehow");
                Assert.AreEqual(token.UserId, token.User.Id, "I've broken the EF key link somehow");

                var token2Task = LoginTokenTasks.GetLoginTokenAsync(context, token.Id);
                token2Task.Wait();
                var token2 = token2Task.Result;
                Assert.AreEqual(token2.UserId, token2.User.Id, "I'ev broken the EF key link somehow");

                Assert.IsNotNull(token2, "A valid login token has come back as null");
                Assert.AreEqual(token.Id, token2.Id, "The token requested is not the token retrieved.");

                LoginTokenTasks.LogoutAsync(context, token2).Wait();

                var token3Task = LoginTokenTasks.GetLoginTokenAsync(context, token.Id);
                token3Task.Wait();
                var token3 = token3Task.Result;

                Assert.IsNull(token3, "After logout the token should return as null.");
            }

            Assert.Pass();
        }
Exemplo n.º 13
0
        public void TestDeactivateUser()
        {
            IConfiguration config = getTestConfiguration();

            using (var context = new SGContext(config))
            {
                var token = quickLogin(context, "admin@localhost", "password");
                Assert.IsTrue(token != null, "Unable to log in as admin user.  Test can't run");

                var testUser  = TryCreateUser(context, token, "deactiveUser@localhost", "password2");
                var userToken = quickLogin(context, "deactiveUser@localhost", "password2");
                Assert.IsTrue(userToken != null, "Unable to log in as activation test user.  Test can't run");

                UserTasks.SetUserActiveAsync(context, token, "deactiveUser@localhost", false).Wait();

                var task = LoginTokenTasks.GetLoginTokenAsync(context, userToken.Id);
                task.Wait();
                var userToken2 = task.Result;
                Assert.IsNull(userToken2, "A user's tokens should not be available after deactivation.");

                userToken = quickLogin(context, "deactiveUser@localhost", "password2");
                Assert.IsNull(userToken2, "A user's should not be able to login after deactivation.");

                UserTasks.SetUserActiveAsync(context, token, "deactiveUser@localhost", true).Wait();

                task = LoginTokenTasks.GetLoginTokenAsync(context, userToken.Id);
                task.Wait();
                var userToken3 = task.Result;
                Assert.IsNotNull(userToken3, "User failed to login after reactivation.");
            }
        }
Exemplo n.º 14
0
 public static List <Teacher> GetOkulIdarecileri(int okulID)
 {
     using (SGContext db = new SGContext())
     {
         var teachers = db.Teacher.Include("User").Where(d => d.Okul.SchoolId == okulID && (d.Unvan == (int)(SG_DAL.Enums.EnumUnvan.Mudur) || d.Unvan == (int)(SG_DAL.Enums.EnumUnvan.MudurYardimcisi)));
         return(teachers.ToList());
     }
 }
Exemplo n.º 15
0
 public static List <Teacher> GetTeacherListBySchoolId(int schID)
 {
     using (SGContext db = new SGContext())
     {
         var list = db.Teacher.Include("User").Include("Okul").Where(d => d.User.IsDeleted == false & d.SchoolId == schID).ToList();
         return(list);
     }
 }
Exemplo n.º 16
0
 public static List <Teacher> GetTeacherList(SG_DAL.Enums.EnumUnvan unvan)
 {
     using (SGContext db = new SGContext())
     {
         var list = db.Teacher.Include("User").Include("Okul").Where(d => d.User.IsDeleted == false && d.Unvan == (int)unvan).ToList();
         return(list);
     }
 }
Exemplo n.º 17
0
 public static Teacher GetTeacherByTCNo(long tcno)
 {
     using (SGContext db = new SGContext())
     {
         var list = db.Teacher.Include("User").Include("Okul").FirstOrDefault(d => d.User.TCKimlik == tcno);
         return(list);
     }
 }
Exemplo n.º 18
0
 public static Teacher GetTeacher(int TeacherId)
 {
     using (SGContext db = new SGContext())
     {
         var teacher = db.Teacher.Include("User").Include("SinavGorevli").Include("Okul").First(d => d.TeacherId == TeacherId);
         return(teacher);
     }
 }
Exemplo n.º 19
0
 public static User GetUserByTCNo(int TCNo)
 {
     using (SGContext db = new SGContext())
     {
         var usr = db.Teacher.Include("User").First(d => d.User.TCKimlik == TCNo);
         return(usr.User);
     }
 }
Exemplo n.º 20
0
        private LoginToken quickGetToken(SGContext context, Int64 tokenId)
        {
            var task = LoginTokenTasks.GetLoginTokenAsync(context, tokenId);

            task.Wait();
            var token = task.Result;

            return(token);
        }
Exemplo n.º 21
0
        public static User GetUserByTeacherId(int TeacherId)
        {
            using (SGContext db = new SGContext())
            {
                var usr = db.Teacher.Include("User").First(d => d.TeacherId == TeacherId);

                return(usr.User);
            }
        }
Exemplo n.º 22
0
        private LoginToken quickLogin(SGContext context, string username, string password)
        {
            var tokenTask = LoginTokenTasks.LoginAsync(context, username, password);

            tokenTask.Wait();
            var token = tokenTask.Result;

            return(token);
        }
Exemplo n.º 23
0
        public void OneTimeTearDown()
        {
            IConfiguration config = getTestConfiguration();

            using (var context = SGContext.CreateAndInitialise(config))
            {
                context.Database.EnsureDeleted();
            }
        }
Exemplo n.º 24
0
        public static bool GorevdenCikar(int tchID, int snOturumID)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var gorevli = db.SinavGorevli.FirstOrDefault(d => d.TeacherId == tchID && d.SinavOturumId == snOturumID);

                    if (gorevli != null)
                    {
                        var setting = SettingManager.GetSettings();

                        if (setting.GenelBasvuru)
                        {
                            var gorevliler = SinavManager.GetSinavGorevliler(snOturumID, (int)SG_DAL.Enums.EnumSinavGorev.Gozetmen);

                            var ogrt = TeacherManager.GetTeacherListForGenelBasvuru();

                            if (gorevliler.Count() > 0)
                            {
                                foreach (var item in ogrt)
                                {
                                    var yenigorevli = SinavManager.GetSinavGorevli(snOturumID, item.TeacherId);

                                    if (yenigorevli == null)
                                    {
                                        gorevli.TeacherId = item.TeacherId;
                                        db.SaveChanges();
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    /*if (gorevli != null)
                     * {
                     *  var okulgorevlileri = db.SinavGorevli.Where(d => d.SchoolId == gorevli.SchoolId && d.SinavOturumId == snOturumID);
                     *  foreach (var item in okulgorevlileri)
                     *  {
                     *      item.si
                     *  }
                     * }*/

                    return(true);
                }
                catch (Exception)
                {
                    return(true);
                }
            }
        }
Exemplo n.º 25
0
 public static Teacher GetTeacherForGenelBasvuru(int TeacherId)
 {
     using (SGContext db = new SGContext())
     {
         var teacher = db.Teacher.Include("User")
                       .Include("Okul")
                       .First(d => d.User.IsDeleted == false && d.GenelBasvuru == true && d.TeacherId == TeacherId);
         return(teacher);
     }
 }
Exemplo n.º 26
0
        public void TestLogin()
        {
            var config = getTestConfiguration();

            using (SGContext context = new SGContext(config))
            {
                var handler = new ApiHandler(context);

                PerformLoginAndTokenTestFor(handler, Defaults.UserAdmin, Defaults.UserAdminPassword);
            }
        }
Exemplo n.º 27
0
 public static List <Teacher> GetTeacherListForGenelBasvuru()
 {
     using (SGContext db = new SGContext())
     {
         var list = db.Teacher.Include("User")
                    .Include("Okul")
                    .Where(d => d.User.IsDeleted == false && d.GenelBasvuru == true && d.Unvan == (int)SG_DAL.Enums.EnumUnvan.Ogretmen)
                    .ToList();
         return(list);
     }
 }
Exemplo n.º 28
0
        public static void GenelBasvuruGuncelle(bool gnlBasvuru)
        {
            HttpCookie myCookie = new HttpCookie("LoginCookie");

            myCookie = HttpContext.Current.Request.Cookies["LoginCookie"];
            Int64 tcno = Convert.ToInt64(myCookie.Value.Split('=')[1].ToString());

            using (SGContext db = new SGContext())
            {
                db.Teacher.Include("User").FirstOrDefault(d => d.User.TCKimlik == tcno).GenelBasvuru = gnlBasvuru;
                db.SaveChanges();
            }
        }
Exemplo n.º 29
0
 private User TryCreateUser(SGContext context, LoginToken token, string email, string password)
 {
     try
     {
         var userTask = UserTasks.CreateUserAsync(context, token, email, "User", password, UserRole.User);
         userTask.Wait();
         var user = userTask.Result;
         return(user);
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 30
0
        public static List <Teacher> GetTeacherListForSinav()
        {
            using (SGContext db = new SGContext())
            {
                var list = new List <Teacher>();

                if (db.Setting.First().GenelBasvuru)
                {
                    list = db.Teacher.Include("User").Where(d => d.User.IsDeleted == false).ToList();
                }

                return(list);
            }
        }