public ActionResult Create(Seflik seflik) { ModelState.Remove("ModifiedUsername"); ModelState.Remove("CreatedOn"); if (ModelState.IsValid) { seflikManager.Insert(seflik); return(RedirectToAction("Index")); } return(View(seflik)); }
// GET: Seflik/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seflik seflik = seflikManager.Find(x => x.Id == id); if (seflik == null) { return(HttpNotFound()); } return(View(seflik)); }
// GET: Seflik/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Seflik seflik = seflikManager.Find(x => x.Id == id); if (seflik == null) { return(HttpNotFound()); } ViewBag.BaskanlikId = new SelectList(baskanlikManager.List(), "Id", "Isim"); ViewBag.MudurlukId = new SelectList(mudurlukManager.List(), "Id", "Isim"); return(View(seflik)); }
public ActionResult Edit(Seflik seflik) { ModelState.Remove("ModifiedUsername"); ModelState.Remove("CreatedOn"); ModelState.Remove("Baskanlik.Isim"); ModelState.Remove("Baskanlik.ModifiedUsername"); ModelState.Remove("Mudurluk.Isim"); ModelState.Remove("Mudurluk.ModifiedUsername"); if (ModelState.IsValid) { Seflik sef = seflikManager.Find(x => x.Id == seflik.Id); sef.Isim = seflik.Isim; sef.BaskanlikId = seflik.Baskanlik.Id; sef.MudurlukId = seflik.Mudurluk.Id; seflikManager.Update(sef); return(RedirectToAction("Index")); } return(View(seflik)); }
protected override void Seed(DatabaseContext context) { Personel admin = new Personel() { SicilNo = FakeData.NumberData.GetNumber(8), Ad = "Nuray", Soyad = "Bilmiyorum", Email = "*****@*****.**", DahiliNumarasi = "2007", KullaniciAdi = "nuray", Sifre = Crypto.HashPassword("123"), IsAdmin = true, CreatedOn = DateTime.Now.AddHours(1), ModifiedOn = DateTime.Now.AddMinutes(65), ModifiedUsername = "******", }; context.Personel.Add(admin); context.SaveChanges(); IzinTipi tip = new IzinTipi() { IzinTuru = "Günlük", RenkKodu = "#000", CreatedOn = DateTime.Now.AddHours(1), ModifiedOn = DateTime.Now.AddMinutes(65), ModifiedUsername = "******", }; context.IzinTipi.Add(tip); context.SaveChanges(); IzinTipi tip2 = new IzinTipi() { IzinTuru = "Saatlik", RenkKodu = "#000", CreatedOn = DateTime.Now.AddHours(1), ModifiedOn = DateTime.Now.AddMinutes(65), ModifiedUsername = "******", }; context.IzinTipi.Add(tip2); context.SaveChanges(); for (int i = 0; i < 5; i++) { Baskanlik bas = new Baskanlik() { Isim = FakeData.NameData.GetCompanyName(), CreatedOn = DateTime.Now.AddHours(1), ModifiedOn = DateTime.Now.AddMinutes(65), ModifiedUsername = "******" }; context.Baskanlik.Add(bas); context.SaveChanges(); Mudurluk mud = new Mudurluk() { Isim = FakeData.NameData.GetCompanyName(), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", Baskanlik = bas, }; context.Mudurluk.Add(mud); context.SaveChanges(); Seflik sef = new Seflik() { Isim = FakeData.NameData.GetCompanyName(), CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", Baskanlik = bas, Mudurluk = mud, }; context.Seflik.Add(sef); context.SaveChanges(); Personel calisan = new Personel() { SicilNo = FakeData.NumberData.GetNumber(8), Ad = FakeData.NameData.GetFirstName(), Soyad = FakeData.NameData.GetSurname(), Email = "*****@*****.**", DahiliNumarasi = "2007", KullaniciAdi = FakeData.NameData.GetFirstName() + FakeData.NameData.GetSurname(), Sifre = "123", IsAdmin = false, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", Baskanlik = bas, Mudurluk = mud, Seflik = sef, }; context.Personel.Add(calisan); context.SaveChanges(); for (int j = 0; j < 2; j++) { Izinler mola = new Izinler() { BaslangicTarihi = DateTime.Now, BitisTarihi = DateTime.Now.AddDays(1), Personel = calisan, IzinTipi = tip, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", }; context.Izinler.Add(mola); Izinler mola2 = new Izinler() { BaslangicTarihi = DateTime.Now, BitisTarihi = DateTime.Now.AddDays(1), Personel = calisan, IzinTipi = tip2, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, ModifiedUsername = "******", }; context.Izinler.Add(mola2); } context.SaveChanges(); } /* * // Adding admin user.. * Personel admin = new Personel() * { * * SicilNo = FakeData.NumberData.GetNumber(8), * Ad = "Nuray", * Soyad="Bilmiyorum", * Email="*****@*****.**", * DahiliNumarasi="2007", * KullaniciAdi="nuray", * Sifre="123", * IsAdmin=true, * CreatedOn=DateTime.Now.AddHours(1), * ModifiedOn=DateTime.Now.AddMinutes(65), * ModifiedUsername="******", * * };*/ }