コード例 #1
0
        public ActionResult Login(string login_numara, string login_password, bool login_rememberme)
        {
            MsgJsonResult result = new MsgJsonResult();

            login_numara   = login_numara?.Trim();
            login_password = login_password?.Trim();

            if (string.IsNullOrEmpty(login_numara) || string.IsNullOrEmpty(login_password))
            {
                result.HasError = true;
                result.Message  = "Öğrenci numarası ve şifre alanlarnı doldurunuz.";
            }
            else
            {
                SiteUsers user = db.Users.AsNoTracking().FirstOrDefault(x => x.Number == login_numara && x.Password == login_password);
                if (user != null)
                {
                    result.HasError = false;
                    //  result.url = "/Share/Paylasim";
                    user.Password = string.Empty;

                    Session["Ogrenci"] = user;
                    result.Message     = "Mahmut";
                }
                else
                {
                    result.HasError = true;
                    result.Message  = "Öğrenci numarası veya şifre yanlış";
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult LostPassword(string lost_email)
        {
            MsgJsonResult result = new MsgJsonResult();

            lost_email = lost_email?.Trim();

            if (string.IsNullOrEmpty(lost_email))
            {
                result.HasError = true;
                result.Message  = "E-Mail address can not be empty.";
            }
            else
            {
                // TODO : KMB Modal Login - Lost Password
                SiteUsers user = db.Users.AsNoTracking().FirstOrDefault(x => x.EMail == lost_email);


                if (user != null)
                {
                    //
                    // TODO : Send password with e-mail.
                    //

                    result.HasError = false;
                    result.Message  = "Password has been sent.";
                }
                else
                {
                    result.HasError = true;
                    result.Message  = "E-Mail adresi kayıtlı değil.";
                }
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ActionResult SaveMultiImage()
        {
            var           text   = System.Web.HttpContext.Current.Request.Form["HelpString"];
            MsgJsonResult result = new MsgJsonResult();

            if (Request.Files.Count > 0)
            {
                var allowedExtensions = new[] { ".jpeg", ".jpg", ".png" };
                //var allowedExtensionsfile = new[] { ".doc", ".docx", ".pdf" };
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];
                    if (allowedExtensions.Contains(Path.GetExtension(file.FileName)))
                    {
                        result.HasError = true;
                    }
                    else
                    {
                        result.HasError = false;
                        result.Message  = "Lütfen .jpg .jpeg .png uzantılı dosya seçiniz....";
                        return(Json(result, JsonRequestBehavior.AllowGet));
                    }
                }
                SiteUsers       user   = Session["Ogrenci"] as SiteUsers;
                UploadMultiFile upload = new UploadMultiFile();
                SiteUsers       user1  = db.Users.Find(user.Id);
                SharedModel     model  = new SharedModel();
                model.Text       = text;
                model.Type       = "images";
                model.Users      = user1;
                model.SharedDate = DateTime.Now;
                db.ShareModels.Add(model);
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];
                    if (result.HasError == true)
                    {
                        string path = Guid.NewGuid() + "-" + Path.GetExtension(file.FileName);
                        file.SaveAs(Server.MapPath("~/UploadFile/images/" + path));
                        upload.SharedModelId = model.Id;
                        upload.FilePath      = path;
                        db.UploadMultiFiles.Add(upload);
                        db.SaveChanges();
                    }
                }
                db.SaveChanges();
                result.HasError = true;
                result.Message  = "Resimler başarılı bir şekilde kaydedildi...";

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                result.HasError = false;
                result.Message  = "Lütfen bir resim seçiniz...";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        public ActionResult VideoPost(string txt, string link)
        {
            MsgJsonResult result = new MsgJsonResult();
            string        linkQ  = link.Trim();

            string[] t     = new string[2];
            string[] words = linkQ.Split('=');
            for (int i = 0; i < words.Length; i++)
            {
                t[i] = words[i];
            }
            int linkCount = t[1].Length;

            if (t[0] == "https://www.youtube.com/watch?v" && linkCount == 11)
            {
                SiteUsers user = Session["Ogrenci"] as SiteUsers;

                SiteUsers   user1 = db.Users.Find(user.Id);
                SharedModel model = new SharedModel();
                model.Text       = txt;
                model.Type       = "video";
                model.Users      = user1;
                model.Path       = "https://www.youtube.com/embed/" + t[1];
                model.SharedDate = DateTime.Now;
                db.ShareModels.Add(model);
                db.SaveChanges();

                result.HasError = true;
                result.Message  = "Video kaydedildi...";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                result.HasError = false;
                result.Message  = "Lütfen youtube linkini  giriniz...";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        public JsonResult Register(string firstname, string lastname, string number, string email, string password)
        {
            MsgJsonResult result = new MsgJsonResult();

            firstname = firstname?.Trim();
            lastname  = lastname?.Trim();
            number    = number?.Trim();
            email     = email?.Trim();
            password  = password?.Trim();

            if (string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(number) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                result.HasError = true;
                result.Message  = "Lütfen, boş alanları doldurunuz.";
            }
            else
            {
                NumberStudent numStudent = db.numberStudents.FirstOrDefault(x => x.Number == number);
                if (numStudent == null)
                {
                    result.HasError = true;
                    result.Message  = "Bu numarada bir öğrenci kayıtlı değil.";
                }
                else
                {
                    SiteUsers user = db.Users.FirstOrDefault(x => x.Number == number || x.EMail == email);
                    if (user != null)
                    {
                        result.HasError = true;
                        result.Message  = "Bu numrada oğrenci kayıtlı.";
                    }
                    else
                    {
                        RoleType rol = new RoleType();
                        user = db.Users.Add(new SiteUsers()
                        {
                            FirstName = firstname,
                            LastName  = lastname,
                            Number    = number,
                            EMail     = email,
                            Password  = password,
                            LastAcces = DateTime.Now,
                            Permisson = "Ogrenci",
                            Resimulr  = "Profile.png"
                        });


                        if (db.SaveChanges() > 0)
                        {
                            result.HasError = false;
                            result.Message  = "Kayıt olustu";

                            user.Password      = string.Empty;
                            Session["Ogrenci"] = user;
                        }
                        else
                        {
                            result.HasError = true;
                            result.Message  = "Bir Hata oluştu.";
                        }
                    }
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }