Ejemplo n.º 1
0
        public static Kullanici KullaniciViewModelToKullanici(KullaniciViewModel model, Kullanici kullanici)
        {
            kullanici.Ad = model.Ad;
            kullanici.Eposta = model.Eposta;
            kullanici.Sifre = model.Sifre;

            return kullanici;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        public ActionResult KullaniciDuzenle(KullaniciViewModel model)
        {
            try
            {
                Kullanici kullanici = kullaniciServis.KullaniciBul(model.Id);
                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.KullaniciDuzenle(kullanici);

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

            }

            return View(model);
        }