Ejemplo n.º 1
0
 public ActionResult Login(User user)
 {
     if (ModelState.IsValid)
     {
         User us = AccountManager.Login(user.TCKimlik, user.Sifre);
         if (us == null)
         {
             TempData["GirisBasarisiz"] = "true";
         }
         else
         {
             TempData["GirisBasarisiz"] = "false";
             if (us.IsAdmin == true)
                 return RedirectToAction("SinavListe", "Sinav");
             else
                 return RedirectToAction("Index", "Home");
         }
         return RedirectToAction("Index", "Home");
     }
     else
     {
         TempData["GirisBasarisiz"] = "true";
         return RedirectToAction("Index", "Home");
     }
 }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult CreateTeacherForIdari(User user, Teacher teacher)
        {
            TempData["EventResult"] = TeacherManager.addTeacher(user, teacher);
            if (((SG_BLL.Tools.Result)TempData["EventResult"]).Status.Equals("error"))
            {
                var schools = SchoolManager.GetSchools();
                var list = new SelectList(schools, "SchoolId", "Ad");
                ViewBag.SchoolList = list;

                var items = new List<UnvanHelper>();
                ResourceManager rm = new ResourceManager("SinavGorevlendirme.Resources.Genel", typeof(TeacherController).Assembly);

                foreach (var unv in Enum.GetValues(typeof(EnumUnvan)))
                {
                    items.Add(new UnvanHelper((int)unv, rm.GetString(unv.ToString())));
                }

                var unvanList = new SelectList(items, "UnvanId", "Unvan");

                ViewBag.UnvanList = unvanList;
                return View();
            }

            return RedirectToAction("CreateTeacherForIdari");
        }
Ejemplo n.º 4
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;

            }
        }
Ejemplo n.º 5
0
        public static Result addTeacher(User newUser, Teacher teacher)
        {
            using (SGContext db = new SGContext())
            {
                try
                {
                    var userRepository = new Repository<User>(db);
                    var user = userRepository.Find(d => d.TCKimlik == newUser.TCKimlik);

                    if (user.Count() > 0)
                    {
                        result = new Result(SystemRess.Messages.hata_ayniTcSistemdeMevcut.ToString(), SystemRess.Messages.hatali_durum.ToString());
                        return result;
                    }
                    else if (string.IsNullOrEmpty(newUser.Sifre))
                    {
                        newUser.Sifre = newUser.TCKimlik.ToString();
                    }
                    var okulRepo = new Repository<School>(db);
                    int okulID = teacher.Okul.SchoolId;
                    var okul = okulRepo.Find(d => d.SchoolId == okulID);
                    teacher.Okul = okul.First();
                    if (teacher.Unvan == 1)
                        newUser.Rol = (int)SG_DAL.Enums.EnumRol.ogretmen;
                    else
                        if (teacher.Unvan == 2 || teacher.Unvan == 3)
                            newUser.Rol = (int)SG_DAL.Enums.EnumRol.idareci;

                    teacher.User = newUser;
                    teacher.GorevSayisi = 0;
                    var teacherRepo = new Repository<Teacher>(db);
                    teacherRepo.Add(teacher);
                    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;
                }
            }
        }
Ejemplo n.º 6
0
        public ActionResult Login(User user)
        {
            if (ModelState.IsValid)
            {
                User us = AccountManager.Login(user.TCKimlik, user.Sifre);
                if (us != null)
                {
                    return RedirectToAction("SinavListe", "Sinav");
                }
                else
                {
                    ModelState.AddModelError("", "Kullanıcı Adı veya Şifre Hatalı!");
                    ViewBag.HataliGiris = "Kullanıcı Adı veya Şifre Hatalı!";
                }

                return View(user);
            }
            else
            {
                return View();
            }
        }
Ejemplo n.º 7
0
 public ActionResult Register(User user)
 {
     Result result = UserManager.CreateUser(user);
     TempData["Status"] = result.Status;
     TempData["Message"] = result.Message;
     return View();
 }
Ejemplo n.º 8
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;
                }
            }
        }
Ejemplo n.º 9
0
        public ActionResult TeacherUpdate(User user, Teacher teacher)
        {
            TempData["EventResult"] = TeacherManager.updateTeacher(user, teacher);

            if (((FormsIdentity)User.Identity).Ticket.UserData == "idareci")
            {
                return RedirectToAction("TeacherEditForIdari", "Teacher", new { OgretmenId = teacher.TeacherId });
            }
            else if (((FormsIdentity)User.Identity).Ticket.UserData == "ogretmen")
            {
                return RedirectToAction("PersonelBilgi", "Teacher", new { OgretmenId = teacher.TeacherId });
            }else
            {
                return RedirectToAction("TeacherEdit", "Teacher", new { OgretmenId = teacher.TeacherId });
            }
        }
Ejemplo n.º 10
0
 public TeacherWrapperModel(User user, Teacher teacher, School okul)
 {
     this.user = user;
     this.teacher = teacher;
     this.okul = okul;
 }