public ActionResult CreateStep1([Bind(Include = "Id,Name,MiddleName,Surname,Company,Phone,Mail,Index,CityId,Address,CentreId,InformingSMS,InformingMail")] Person person) { if (!(person.Name != null && person.Surname != null || person.Company != null)) { ModelState.AddModelError("", "Необходимо указать либо ФИО, либо название компании"); } if (!(person.CityId != null && person.Address != null || person.CentreId != null)) { ModelState.AddModelError("", "Необходимо либо выбрать пункт выдачи, либо указать адрес"); } if (person.InformingMail && person.Mail == null) { ModelState.AddModelError("", "Для отправки уведомлений необходимо указать электронную почту"); } if (person.InformingSMS && person.Phone == null) { ModelState.AddModelError("", "Для отправки уведомлений необходимо указать номер телефона"); } if (ModelState.IsValid) { Person p = db.Persons.Add(person); db.SaveChanges(); db.AccountReferences.Add(new AccountReference { UserId = db.Users.Where(a => a.Login == User.Identity.Name).Select(a => a.Id).First(), PersonId = p.Id }); db.SaveChanges(); return(RedirectToAction("CreateStep2", new { personIdFrom = p.Id })); } InitSelectLists(); return(View(person)); }
public ActionResult DeleteReference(int id) { AccountReference reference = db.AccountReferences.Find(id); db.AccountReferences.Remove(reference); db.SaveChanges(); TempData["alertMessage"] = "Зависимость удалена."; return(RedirectToAction("Index", "UserSettings")); }
public IHttpActionResult PromediaPuntuacion(string idCond) { int idC = Int32.Parse(idCond); var Promedio = db.Set <Viaje>().Where(r => r.IdConductor == idC).Average(r => r.puntuacion); Conductor objetoConductor = (from s in db.Set <Conductor>() where (s.Id == idC) select s).FirstOrDefault(); objetoConductor.puntuacion = Convert.ToInt32(Promedio); db.SaveChanges(); string retorno = objetoConductor.puntuacion.ToString(); return(Ok(retorno)); }
public ActionResult CreateUserConfirmed(User user) { db.Users.Add(user); db.SaveChanges(); TempData["alertMessage"] = "Аккаунт успешно создан."; return(RedirectToAction("AccountsSettings")); }
public ActionResult Create([Bind(Include = "Id,PersonIdFrom,PersonIdTo,TariffId,Description,Weight,Length,Width,Height,NumberOfPackages,Cost,DeclaredValue")] Package package) { if (ModelState.IsValid) { db.Packages.Add(package); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonIdFrom = new SelectList(db.Persons, "Id", "Name", package.PersonIdFrom); ViewBag.PersonIdTo = new SelectList(db.Persons, "Id", "Name", package.PersonIdTo); ViewBag.TariffId = new SelectList(db.Tariffs, "Id", "Name", package.TariffId); return(View(package)); }
private void btnEkle_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); Admin ad = new Admin(); ad.Adi = txtAd.Text; ad.Adres = txtAdres.Text; ad.DogumTarihi = dtDogumTarihi.Value; ad.KullaniciAdi = txtKullaniciAdi.Text; ad.Mail = txtMail.Text; ad.Sifre = txtSifre.Text; ad.Soyadi = txtSoyad.Text; ad.Telefon = txtTel.Text; ad.Unvan = txtUnvan.Text; db.AdminSet.Add(ad); db.SaveChanges(); MessageBox.Show("Kaydınız oluşturulmuştur."); this.Close(); FrmAdminEkrani frm = new FrmAdminEkrani(); frm.Show(); }
private void btnEkle_Click(object sender, EventArgs e) { if (DateTime.Now.Year - dtDogumTarihi.Value.Year >= 12) { ModelDBContainer db = new ModelDBContainer(); Kullanici klnc = new Kullanici(); klnc.TCKimlikNo = txtKimlikNo.Text; klnc.Adi = txtAd.Text; klnc.Soyadi = txtSoyad.Text; klnc.Adres = txtAdres.Text; klnc.CezaDurumu = false; klnc.DogumTarihi = dtDogumTarihi.Value; klnc.KullaniciAdi = txtKullaniciAdi.Text; klnc.Mail = txtMail.Text; klnc.Sifre = txtSifre.Text; klnc.Telefon = txtTel.Text; klnc.Unvan = txtUnvan.Text; db.KullaniciSet.Add(klnc); db.SaveChanges(); MessageBox.Show("Kaydınız Oluşturulmuştur, Lütfen Giriş Yapınız"); this.Close(); } else { MessageBox.Show("12 Yaşından Küçükler Kütüphanemize Üye Olamaz", "Bilgi"); this.Close(); } }
public ActionResult CreateStep1([Bind(Include = "Id,Name,MiddleName,Surname,Company,Phone,Mail,Index,CityId,Address,CentreId,InformingSMS,InformingMail")] Person person) { if (ModelState.IsValid) { Person p = db.Persons.Add(person); db.SaveChanges(); db.AccountReferences.Add(new AccountReference { UserId = db.Users.Where(a => a.Login == User.Identity.Name).Select(a => a.Id).First(), PersonId = p.Id }); db.SaveChanges(); return(RedirectToAction("CreateStep2", new { personIdFrom = p.Id })); } InitSelectLists(); return(View(person)); }
private void btnKitapSil_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); ID = (int)dgEkran.SelectedRows[0].Cells[0].Value; var ktp = db.KitapSet.Find(ID); db.KitapSet.Remove(ktp); db.SaveChanges(); MessageBox.Show("İşleminiz gerçekleştirilmiştir."); var sorgu = (from k in db.KitapSet select new { k.Id, k.KitapAdi, k.SayfaSayisi, k.TasnifNo, k.Kategori.KategoriAdi, k.YayinEvi.YayinEviAdi, k.KiralikDurumu, k.KiralanmaTarihi, k.İadeTarihi, k.EklenmeTarihi, YazarAdSoyad = k.Yazar.YazarAdi + " " + k.Yazar.YazarSoyadi }).ToList(); dgEkran.DataSource = sorgu; }
public string CancelarViaje(string idViaje) { try { int idV = Int32.Parse(idViaje); Viaje viajesolicitado = dbFlota.Set <Viaje>().FirstOrDefault(p => p.IdViaje == idV); viajesolicitado.estadoViaje = "cancelado"; dbFlota.SaveChanges(); string estadoViaje = viajesolicitado.estadoViaje; return(estadoViaje); } catch (Exception ex) { string respuesta = ex.Message; return(respuesta); } }
private void btnAdminSil_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); ID = (int)dgEkran.SelectedRows[0].Cells[0].Value; var ad = db.AdminSet.Find(ID); db.AdminSet.Remove(ad); db.SaveChanges(); MessageBox.Show("İşleminiz gerçekleştirilmiştir."); tsBtnAdminler.PerformClick(); }
public ActionResult DeleteRecord(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Record record = db.Records.Find(id); if (record == null) { return(HttpNotFound()); } int PackageId = record.Package.Id; db.Records.Remove(record); db.SaveChanges(); return(RedirectToAction("Details", new { id = PackageId })); }
public IHttpActionResult RegistrarConductor([FromBody] Conductor datos) { try { Conductor conductor = db.Set <Conductor>().Add(datos); db.SaveChanges(); if (conductor == null) { throw new Exception("No se puede ingresar datos nulos o mal completados"); } return(Ok("true")); } catch (Exception) { throw new Exception("Datos de registro incorrectos"); } }
public IHttpActionResult ComentarioViaje(Viaje vj) { //Se modifica todos los campos del viaje, los que cambien los guardara y los que no se mantendran Viaje modViaje = db.Set <Viaje>().FirstOrDefault(c => c.IdViaje == vj.IdViaje); modViaje.puntuacion = vj.puntuacion; modViaje.comentarioCliente = vj.comentarioCliente; try { db.SaveChanges(); } catch (Exception) { throw new Exception("No existe ese id"); } return(Ok(modViaje)); }
public IHttpActionResult RegistrarCliente([FromBody] Cliente datos) { try { Cliente cliente = db.Set <Cliente>().Add(datos); db.SaveChanges(); if (cliente == null) { string respuesta = "El cliente es nulo"; return(Ok(respuesta)); } return(Ok("true")); } catch (Exception ex) { string respuesta = ex.Message; return(Ok(respuesta)); } }
private void btnGuncelle_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); var klnc = db.KullaniciSet.Find(FrmGiris.ID); klnc.Adi = txtAd.Text; klnc.TCKimlikNo = txtKimlikNo.Text; klnc.Adres = txtAdres.Text; klnc.DogumTarihi = dtDogumTarihi.Value; klnc.KullaniciAdi = txtKullaniciAdi.Text; klnc.Mail = txtMail.Text; klnc.Sifre = txtSifre.Text; klnc.Soyadi = txtSoyad.Text; klnc.Telefon = txtTel.Text; klnc.Unvan = txtUnvan.Text; db.SaveChanges(); this.Hide(); FrmKullaniciEkrani frm = new FrmKullaniciEkrani(); frm.Show(); }
private void btnGuncelle_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); var ad = db.AdminSet.Find(FrmAdminEkrani.ID); ad.Adi = txtAd.Text; ad.Adres = txtAdres.Text; ad.DogumTarihi = dtDogumTarihi.Value; ad.KullaniciAdi = txtKullaniciAdi.Text; ad.Mail = txtMail.Text; ad.Sifre = txtSifre.Text; ad.Soyadi = txtSoyad.Text; ad.Telefon = txtTel.Text; ad.Unvan = txtUnvan.Text; db.SaveChanges(); this.Hide(); MessageBox.Show("Güncelleme işlemi başarı ile gerçekleştirilmiştir."); FrmAdminEkrani frm = new FrmAdminEkrani(); frm.Show(); }
private void btnEkle_Click(object sender, EventArgs e) { ModelDBContainer db = new ModelDBContainer(); Kitap ktp = new Kitap(); ktp.KitapAdi = txtKitapAdi.Text; ktp.SayfaSayisi = int.Parse(txtSayfaSayisi.Text); ktp.EklenmeTarihi = dtEklenmeTarihi.Value; bool yazarVarMi = db.YazarSet.Where(y => y.YazarAdi == txtYazarAdi.Text && y.YazarSoyadi == txtYazarSoyadi.Text).ToList().Count > 0; if (yazarVarMi) { ktp.YazarId = db.YazarSet.Where(y => y.YazarAdi == txtYazarAdi.Text && y.YazarSoyadi == txtYazarSoyadi.Text).FirstOrDefault().Id; } else { var yzr = new Yazar(); yzr.YazarAdi = txtYazarAdi.Text; yzr.YazarSoyadi = txtYazarSoyadi.Text; db.YazarSet.Add(yzr); ktp.YazarId = yzr.Id; } bool yEviVarMi = db.YayinEviSet.Where(y => y.YayinEviAdi == txtYayinEvi.Text).ToList().Count > 0; if (yEviVarMi) { ktp.YayinEviId = db.YayinEviSet.Where(y => y.YayinEviAdi == txtYayinEvi.Text).FirstOrDefault().Id; } else { var yEv = new YayinEvi(); yEv.YayinEviAdi = txtYayinEvi.Text; db.YayinEviSet.Add(yEv); ktp.YayinEviId = yEv.Id; } bool ktgVarmi = db.KategoriSet.Where(k => k.KategoriAdi == txtKategori.Text).ToList().Count > 0; if (ktgVarmi) { ktp.KategoriId = db.KategoriSet.Where(k => k.KategoriAdi == txtKategori.Text).FirstOrDefault().Id; } else { var ktg = new Kategori(); ktg.KategoriAdi = txtKategori.Text; db.KategoriSet.Add(ktg); ktp.KategoriId = ktg.Id; } Tasnif tsnf = new Tasnif(); ktp.TasnifNo = tsnf.Tasnifle(txtKitapAdi.Text); db.KitapSet.Add(ktp); db.SaveChanges(); }
public IHttpActionResult GetModClienteId(Cliente cl) { if (!ModelState.IsValid) { return(BadRequest("Datos invalidos")); } //Se modifica todos los campos de cliente, los que cambien los guardara y los que no se mantendran Cliente modCliente = db.Set <Cliente>().FirstOrDefault(c => c.Id == cl.Id); modCliente.Id = cl.Id; modCliente.nombre = cl.nombre; modCliente.email = cl.email; modCliente.contrasena = cl.contrasena; modCliente.cuentabancaria = cl.cuentabancaria; modCliente.dni = cl.dni; modCliente.fechanacimiento = cl.fechanacimiento; modCliente.foto = cl.foto; modCliente.telefono = cl.telefono; try { db.SaveChanges(); return(Ok(modCliente)); } catch (Exception ex) { string respuesta = ex.Message; return(Ok(respuesta)); } }