private void Button_Click_2(object sender, RoutedEventArgs e) { Member member = new Member(); member.FullName = txtFullName.Text; member.address = txtAddress.Text; member.RegisteredDate = DateTime.Today; member.BooksPerBorrow = txtBooksAtATime.Text; member.phone = txtPhone.Text; member.email = txtEmail.Text; member.ExpirationDate = datePicker.SelectedDate; MemberDataAccess.Insert(member); }
public ActionResult InsertMember(MEMBER member) { try { if (ModelState.IsValid) { if (Request.Files.Count > 0) { string dosyaAdi = Guid.NewGuid().ToString().Replace("-", ""); string uzanti = Path.GetExtension(Request.Files[0].FileName); string tamYolYeri = "~/Content/images/members/" + dosyaAdi + uzanti; Request.Files[0].SaveAs(Server.MapPath(tamYolYeri)); member.IMAGE = dosyaAdi + uzanti; } else { ViewBag.Error = "Resim eklemelisiniz."; PopulateStateDropdownList(member.STATE_ID); return(View("MemberInsert", member)); } memberDA.Insert(member); return(RedirectToAction("Members", "Admin")); } else { ViewBag.Error = "Try Again."; PopulateStateDropdownList(member.STATE_ID); return(View("MemberInsert", member)); } } catch (Exception ex) { ViewBag.Error = "Try Again."; PopulateStateDropdownList(member.STATE_ID); return(View("MemberInsert", member)); } }