public IActionResult EditAddressSubmit(Address myAddress, int mySponsorId) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } if (!ModelState.IsValid) { return(RedirectToAction("EditAddress", myAddress.addressId)); } AddressRelations oldRel = new AddressRelations(); AddressRelations newRel = new AddressRelations(); oldRel = revenueManager.getAddressRelations(myAddress.addressId); if (oldRel.sponsorId != mySponsorId) { revenueManager.Remove(oldRel); revenueManager.SaveChanges(); newRel.sponsorId = mySponsorId; newRel.addressId = myAddress.addressId; revenueManager.Add(newRel); revenueManager.SaveChanges(); } else { newRel = oldRel; } revenueManager.Update(myAddress); revenueManager.SaveChanges(); return(RedirectToAction("ViewSponsor", new { mySponsorId = newRel.sponsorId })); }
public IActionResult AddAddressSubmit(Address myAddress, int mySponsorId) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } //submit new address to db if (!ModelState.IsValid) { return(RedirectToAction("AddAddress")); } revenueManager.Add(myAddress); revenueManager.SaveChanges(); AddressRelations rel = new AddressRelations(); rel.sponsorId = mySponsorId; Address address = new Address(); address = revenueManager.newestAddress(); rel.addressId = address.addressId; revenueManager.Add(rel); revenueManager.SaveChanges(); return(RedirectToAction("ViewSponsor", new { mySponsorId = rel.sponsorId })); }
public IActionResult EditAddress(int myAddressId) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } Address address = new Address(); address = revenueManager.getAddress(myAddressId); AddressRelations rel = new AddressRelations(); rel = revenueManager.getAddressRelations(myAddressId); ViewBag.selectList = revenueManager.getList(rel.sponsorId); return(View(address)); }
public IActionResult DeleteAddressSubmit(Address myAddress) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } //delete address //if (!ModelState.IsValid) return RedirectToAction("Index"); AddressRelations rel = new AddressRelations(); rel = revenueManager.getAddressRelations(myAddress.addressId); revenueManager.Remove(rel); revenueManager.SaveChanges(); revenueManager.Remove(myAddress); revenueManager.SaveChanges(); return(RedirectToAction("Index")); }