public ActionResult Create(int vendorId) { VendorAddress vendoraddress = new VendorAddress(); vendoraddress.VendorID = vendorId; ViewBag.PossibleVendorAddressCategories = vendoraddresscategoryRepository.All; ViewBag.PossibleCountries = countryRepository.All; return View(vendoraddress); }
public ActionResult Create(VendorAddress vendoraddress,int vendorId) { if (ModelState.IsValid) { vendoraddressRepository.InsertOrUpdate(vendoraddress); vendoraddressRepository.Save(); return RedirectToAction("Index",new { vendorId=vendorId }); } else { ViewBag.PossibleVendorAddressCategories = vendoraddresscategoryRepository.All; ViewBag.PossibleCountries = countryRepository.All; return View(vendoraddress); } }
public ActionResult Edit(VendorAddress vendoraddress,int vendorId) { if (ModelState.IsValid) { vendoraddressRepository.InsertOrUpdate(vendoraddress); vendoraddressRepository.Save(); return RedirectToAction("Index",new { vendorId=vendorId }); } else { ViewBag.PossibleVendorAddressCategories = vendoraddresscategoryRepository.All; ViewBag.PossibleCountries = countryRepository.All; if (vendoraddress.CountryID.HasValue) { ViewBag.PossibleStates = stateRepository.FindAllByCountryID(vendoraddress.CountryID.Value); } return View(vendoraddress); } }
public ViewResult Search(VendorAddress searchVendorAddress,int vendorId) { if(searchVendorAddress!=null) { } return View("Index",vendoraddressRepository.AllIncluding(vendorId,vendoraddress => vendoraddress.Vendor, vendoraddress => vendoraddress.VendorAddressCategory, vendoraddress => vendoraddress.Country, vendoraddress => vendoraddress.State)); }
public void InsertOrUpdate(VendorAddress vendoraddress) { if (vendoraddress.VendorAddressID == default(int)) { // New entity context.VendorAddress.Add(vendoraddress); } else { // Existing entity context.Entry(vendoraddress).State = EntityState.Modified; } }