public ActionResult Create(int companyId)
 {
     CompanyAddress companyaddress = new CompanyAddress();
     companyaddress.CompanyID = companyId;
     ViewBag.PossibleCompanyAddressCategories = companyaddresscategoryRepository.All;
     ViewBag.PossibleCountries = countryRepository.All;
     return View(companyaddress);
 }
 public ActionResult Create(CompanyAddress companyaddress, int companyId)
 {
     if (ModelState.IsValid)
     {
         companyaddressRepository.InsertOrUpdate(companyaddress);
         companyaddressRepository.Save();
         return RedirectToAction("Index", new { companyId=companyId });
     }
     else
     {
         ViewBag.PossibleCompanyAddressCategories = companyaddresscategoryRepository.All;
         ViewBag.PossibleCountries = countryRepository.All;
         return View(companyaddress);
     }
 }
 public ActionResult Edit(CompanyAddress companyAddress, int companyId)
 {
     if (ModelState.IsValid)
     {
         companyaddressRepository.InsertOrUpdate(companyAddress);
         companyaddressRepository.Save();
         return RedirectToAction("Index", new { companyId = companyId });
     }
     else
     {
         ViewBag.PossibleCompanyAddressCategories = companyaddresscategoryRepository.All;
         ViewBag.PossibleCountries = countryRepository.All;
         if (companyAddress.CountryID.HasValue)
         {
             ViewBag.PossibleStates = stateRepository.FindAllByCountryID(companyAddress.CountryID.Value);
         }
         return View(companyAddress);
     }
 }
 public ViewResult Search(CompanyAddress searchCompanyAddress, int companyId)
 {
     if (searchCompanyAddress != null)
     {
     }
     return View("Index", companyaddressRepository.AllIncluding(companyId, companyaddress => companyaddress.Company, companyaddress => companyaddress.CompanyAddressCategory, companyaddress => companyaddress.Country, companyaddress => companyaddress.State));
 }
Example #5
0
 public void InsertOrUpdate(CompanyAddress companyaddress)
 {
     if (companyaddress.CompanyAddressID == default(int)) {
         // New entity
         context.CompanyAddress.Add(companyaddress);
     } else {
         // Existing entity
         context.Entry(companyaddress).State = EntityState.Modified;
     }
 }