Пример #1
0
        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 }));
        }
Пример #2
0
        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 }));
        }
Пример #3
0
        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));
        }
Пример #4
0
        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"));
        }