Пример #1
0
        public static Kullanici KullaniciViewModelToKullanici(KullaniciViewModel model, Kullanici kullanici)
        {
            kullanici.Ad = model.Ad;
            kullanici.Eposta = model.Eposta;
            kullanici.Sifre = model.Sifre;

            return kullanici;
        }
Пример #2
0
        public static KullaniciViewModel KullaniciToKullaniciViewModel(Kullanici kullanici)
        {
            KullaniciViewModel model = new KullaniciViewModel();

            model.Ad = kullanici.Ad;
            model.Eposta = kullanici.Eposta;
            model.Id = kullanici.Id;
            model.KucukResim = kullanici.KucukProfilResim;
            model.Sifre = kullanici.Sifre;

            return model;
        }
Пример #3
0
        public ActionResult KullaniciEkle(KullaniciViewModel model)
        {
            try
            {
                Kullanici kullanici = new Kullanici();
                kullanici = ViewModelToModel.KullaniciViewModelToKullanici(model, kullanici);
                var dosya = model.Resim;

                if (dosya != null && dosya.ContentLength > 0)
                {
                    // resmin ismini değiştir.
                    var fileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(dosya.FileName);

                    // dosya dizinlerinin yollarını oluştur.
                    var orijinalResimDizin = Server.MapPath("~/Images/uploads/Kullanici");
                    var buyukResimDizin = Server.MapPath("~/Images/uploads/Kullanici/Buyuk");
                    var kucukResimDizin = Server.MapPath("~/Images/uploads/Kullanici/Kucuk");

                    // dizin yoksa oluştur.
                    if (!Directory.Exists(orijinalResimDizin))
                    {
                        Directory.CreateDirectory(orijinalResimDizin);
                        Directory.CreateDirectory(buyukResimDizin);
                        Directory.CreateDirectory(kucukResimDizin);
                    }

                    // dosyayı kaydet
                    dosya.SaveAs(Path.Combine(orijinalResimDizin, fileName));

                    // resimleri farklı boyutlarda kaydet.
                    ImageManager.SaveResizedImage(Image.FromFile(Path.Combine(orijinalResimDizin, fileName)), new Size(200, 200), kucukResimDizin, fileName);

                    kullanici.OrjinalProfilResim = Path.Combine("Images/uploads/Kullanici/", fileName);
                    kullanici.KucukProfilResim = Path.Combine("Images/uploads/Kullanici/Kucuk/", fileName);
                    kullanici.KayitTarihi = DateTime.Now;
                }

                kullaniciServis.KullaniciEkle(kullanici);

                return RedirectToAction("Kullanicilar");
            }
            catch (Exception ex)
            {

            }

            return View(model);
        }
Пример #4
0
 public int KullaniciEkle(Kullanici kullanici)
 {
     db.Kullanici.Add(kullanici);
     return db.SaveChanges();
 }
Пример #5
0
 public void KullaniciDuzenle(Kullanici kullanici)
 {
     db.Entry(kullanici).State = EntityState.Modified;
     db.SaveChanges();
 }