Example #1
0
        public ActionResult AddAddress(AddressVm vm)
        {
            if (ModelState.IsValid)
            {
                var model = new Address();
                model.AddressFirst  = vm.AddressFirst;
                model.AddressSecond = vm.AddressSecond;
                model.PostalCode    = vm.PostalCode;
                model.City          = vm.City;
                model.Country       = vm.Country;

                addressService.Add(model);

                var uAddress = new UserAddress();
                uAddress.UserId    = vm.UserId;
                uAddress.AddressId = model.AddressId;

                userAddressService.Add(uAddress);

                return(RedirectToAction("Loggedin", "Address"));
            }
            else
            {
                ModelState.AddModelError("", "You have to fill all required fields.");
                return(View());
            }
        }
 public ActionResult AddAddress(UserAddress userAddress)
 {
     userAddress.UserId = Convert.ToInt32(Session["Id"]);
     _userAddressService.Add(userAddress);
     return(RedirectToAction("UserAccount"));
 }