Ejemplo n.º 1
0
        public ActionResult Create(Uye uye, HttpPostedFileBase Foto)
        {
            mvcblogDB db = new mvcblogDB();

            if (ModelState.IsValid)
            {
                if (Foto != null)
                {
                    WebImage img      = new WebImage(Foto.InputStream);
                    FileInfo fotoinfo = new FileInfo(Foto.FileName);

                    string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension;
                    img.Resize(150, 150);
                    img.Save("~/Uploads/UyeFoto/" + newfoto);
                    uye.Foto    = "/Uploads/UyeFoto/" + newfoto;
                    uye.YetkiId = 2;
                    db.Uyes.Add(uye);
                    db.SaveChanges();
                    Session["uyeid"]        = uye.UyeId;
                    Session["kullaniciadi"] = uye.KullaniciAdi;
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("Fotoğraf", "Fotoğraf seçiniz");
                }
            }
            return(View(uye));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Uye uye, string Sifre, int id, HttpPostedFileBase Foto)
        {
            mvcblogDB db = new mvcblogDB();

            if (ModelState.IsValid)
            {
                var uyes = db.Uyes.Where(u => u.UyeId == id).SingleOrDefault();
                if (Foto != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(uye.Foto)))
                    {
                        System.IO.File.Delete(Server.MapPath(uyes.Foto));
                    }
                    WebImage img      = new WebImage(Foto.InputStream);
                    FileInfo fotoinfo = new FileInfo(Foto.FileName);

                    string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension;
                    img.Resize(150, 150);
                    img.Save("~/Uploads/UyeFoto/" + newfoto);
                    uyes.Foto = "/Uploads/UyeFoto/" + newfoto;
                }
                uyes.AdSoyad      = uye.AdSoyad;
                uyes.KullaniciAdi = uye.KullaniciAdi;
                uyes.Email        = uye.Email;
                db.SaveChanges();
                Session["kullaniciadi"] = uye.KullaniciAdi;
                return(RedirectToAction("Index", "Home", new { id = uyes.UyeId }));
            }
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            mvcblogDB db  = new mvcblogDB();
            var       uye = db.Uyes.Where(u => u.UyeId == id).SingleOrDefault();

            if (Convert.ToInt32(Session["uyeid"]) != uye.UyeId)
            {
                return(HttpNotFound());
            }
            return(View(uye));
        }
Ejemplo n.º 4
0
        public ActionResult Login(Uye uye)
        {
            mvcblogDB db    = new mvcblogDB();
            var       login = db.Uyes.Where(u => u.KullaniciAdi == uye.KullaniciAdi).SingleOrDefault();

            if (login.KullaniciAdi == uye.KullaniciAdi && login.Email == uye.Email && login.Sifre == uye.Sifre)
            {
                Session["uyeid"]        = login.UyeId;
                Session["kullaniciadi"] = login.KullaniciAdi;
                Session["yetkiid"]      = login.YetkiId;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Uyari = "Kullanıcı adı, şifre veya mail yanlış.";
                return(View());
            }
        }