public ActionResult Register(string gender, Signup model) { LibraryDbEntities db = new LibraryDbEntities(); Address ob1 = new Address(); ob1.country = model.country; db.Addresses.Add(ob1); db.SaveChanges(); int latestId = ob1.member_address_id; Member ob2 = new Member(); ob2.user_id = 1; ob2.member_address_id = latestId; ob2.name = model.name; ob2.email = model.email; ob2.user_name = model.user_name; ob2.phone = model.phone; ob2.gender = gender; ob2.password = model.password; db.Members.Add(ob2); db.SaveChanges(); return(RedirectToAction("Index")); }
// Butun kitablari cedvelde gostermek public void FillBooks() { dgvBooks.Rows.Clear(); foreach (Models.Book book in db.Books.OrderBy(o => o.Name).ToList()) { dgvBooks.Rows.Add(book.Id, book.Name, book.Count); } db.SaveChanges(); }
// Cedvele userleri doldurmaq public void FillUsers() { dgvUsers.Rows.Clear(); foreach (User user in db.Users.OrderBy(o => o.Number).ToList()) { dgvUsers.Rows.Add(user.Id, user.Number, user.Name, user.Surname, user.Phone, user.Email); } db.SaveChanges(); }
public ActionResult Create([Bind(Include = "member_id,user_id,member_address_id,name,email,user_name,gender,phone,password")] Member member) { if (ModelState.IsValid) { db.Members.Add(member); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.member_address_id = new SelectList(db.Addresses, "member_address_id", "country", member.member_address_id); ViewBag.user_id = new SelectList(db.Admins, "user_id", "user_name", member.user_id); return(View(member)); }
private void btnOrder_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cmbUser.Text)) { MessageBox.Show("İstifadəçini seçin"); return; } else if (string.IsNullOrEmpty(cmbBook.Text)) { MessageBox.Show("Götürmək istədiyiniz kitabı seçin"); return; } if (selectedUser.Orders.Count >= 1) { MessageBox.Show("Maximum 1 kitab götürmək icazəniz var. Götürdüyünüz kitabı qaytardıqdan sonra kitab əldə edə bilərsiniz."); return; } if (selectedBook.Count > 0) // database-də bu kitabdan varsa.. { Order order = new Order { StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(1), BookId = selectedBook.Id, UserId = selectedUser.Id, DelayPrice = 5, AdminId = null, IsFinish = false }; db.Orders.Add(order); db.SaveChanges(); db.Books.Find(selectedBook.Id).Count -= 1; db.SaveChanges(); MessageBox.Show("Sifariş qeydə alındı"); cmbBook.Text = ""; FillLabel(); } else { MessageBox.Show(selectedBook.Name + " kitablarının hamısı sifariş olunub!"); return; } }
private void btnRegister_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtSurname.Text) || string.IsNullOrEmpty(txtEmail.Text) || string.IsNullOrEmpty(txtPassword.Text)) { MessageBox.Show("Formanı tam doldurun"); return; } else if (!txtEmail.Text.Contains('@')) { MessageBox.Show("Yalnış email adresi."); } else { Admin admin = new Admin() { Name = txtName.Text, Surname = txtSurname.Text, Email = txtEmail.Text, Password = txtPassword.Text }; db.Admins.Add(admin); db.SaveChanges(); MessageBox.Show("Qeydiyyatdan keçdiniz"); this.Close(); } }
//[Route("Kullanici/kitapAl")] public ActionResult kitapAl(int?isbn) { var model = db.Kitaplar.ToList(); //var aa = FormsAuthentication.GetAuthCookie(userName) Kullanicilar usersInDb = db.Kullanicilar.FirstOrDefault(x => x.isim == User.Identity.Name); if (isbn != null) { usersInDb.kitap = isbn; db.SaveChanges(); return(View("Search")); } else { //db.SaveChanges(); return(View(model)); } }
public ActionResult kitapEkle(string kitapAdi, int Isbn) { var kitap = new Kitaplar(); kitap.Kitap_Adı = kitapAdi; kitap.ISBN = Isbn; db.Kitaplar.Add(kitap); db.SaveChanges(); return(View()); }
// kitabi geri odemek private void btnPay_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(cmbUser.Text)) { MessageBox.Show("İstifadəçini seçin"); return; } Book book = db.Books.Find(selectedOrder.BookId); book.Count += 1; db.SaveChanges(); Order order = db.Orders.Find(selectedOrder.Id); db.Orders.Remove(order); db.SaveChanges(); MessageBox.Show("Kitab geri qaytarıldı və siz artıq yenidən kitab götürə bilərsiniz!"); FillLabel(); }