public IActionResult Duzenle() { var id = HttpContext.Session.GetInt32("id"); SistemYoneticisi yonetici = db.SistemYoneticisi.Where(x => x.ID == id).Include(x => x.Profil).SingleOrDefault(); return(View(yonetici)); }
public IActionResult Goruntule(int id) { Duyuru duyuru = db.Duyurular.Find(id); var yetki = HttpContext.Session.GetInt32("yetki"); var kisiid = (int)HttpContext.Session.GetInt32("id"); if (yetki == 3) { BirimKoordinatoru koordinator = db.BirimKoordinatorleri.Where(x => x.ID == kisiid).Include(x => x.Profil).SingleOrDefault(); ViewBag.EkleyenKisi = koordinator.Profil.Ad + " " + koordinator.Profil.Soyad; } if (yetki == 2) { Moderator moderator = db.Moderatorler.Where(x => x.ID == kisiid).Include(x => x.Profil).SingleOrDefault(); ViewBag.EkleyenKisi = moderator.Profil.Ad + " " + moderator.Profil.Soyad; } if (yetki == 1) { SistemYoneticisi yonetici = db.SistemYoneticisi.Where(x => x.ID == kisiid).Include(x => x.Profil).SingleOrDefault(); ViewBag.EkleyenKisi = yonetici.Profil.Ad + " " + yonetici.Profil.Soyad; } return(View(duyuru)); }
public IActionResult Duzenle(SistemYoneticisi update, string img) { var id = HttpContext.Session.GetInt32("id"); SistemYoneticisi anaveri = db.SistemYoneticisi.Where(x => x.ID == id).Include(x => x.Profil).SingleOrDefault(); var yetki = HttpContext.Session.GetInt32("yetki"); var filepath = @"wwwroot/profile_images"; if (string.IsNullOrEmpty(img)) { } else { var t = img.Replace("data:image/jpeg;base64,", ""); byte[] imagebytes = Convert.FromBase64String(t); string filename = "IMG_" + id + "_" + DateTime.UtcNow.ToString("yyyyMMdd_hhmmss") + new Random().Next(0, 99); var ext = ".png"; filename += ext; string fullpath = Path.Combine(filepath, filename); using (var stream = new FileStream(fullpath, FileMode.Create, FileAccess.ReadWrite)) { try { using (BinaryWriter bw = new BinaryWriter(stream)) { bw.Write(imagebytes); } anaveri.Profil.Fotograf = fullpath.Replace("wwwroot", ""); } catch (Exception ex) { return(Content("Fotoğraf yüklenirken bir sorun oluştu. : " + ex.Message)); } } } if (!string.IsNullOrEmpty(update.Profil.Sifre)) { SHA1 sha = new SHA1CryptoServiceProvider(); string sifrelenmisveri = Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(update.Profil.Sifre))); update.Profil.Sifre = sifrelenmisveri; anaveri.Profil.Sifre = update.Profil.Sifre; } anaveri.Profil.Ad = update.Profil.Ad; anaveri.Profil.Adres = update.Profil.Adres; anaveri.Profil.Email = update.Profil.Email; anaveri.Profil.Il = update.Profil.Il; anaveri.Profil.Ilce = update.Profil.Ilce; anaveri.Profil.KullaniciAdi = update.Profil.KullaniciAdi; anaveri.Profil.Sokak = update.Profil.Sokak; anaveri.Profil.Soyad = update.Profil.Soyad; anaveri.Profil.Telefon = update.Profil.Telefon; db.SaveChanges(); return(Redirect("~/Home/Index")); }