Exemplo n.º 1
0
        public ActionResult SelectAddress(long id /*zip code id.*/, long apartamentId, long buildingId, long streetId,
                                          long cityId, long stateId, long countryId, String returnTo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var v = new ViewAddress
                    {
                        ApartamentID = apartamentId,
                        BuildingID   = buildingId,
                        StreetID     = streetId,
                        CityID       = cityId,
                        StateID      = stateId,
                        CountryID    = countryId,
                        ZipCodeID    = id
                    };
                    long?addrId = null;
                    if (ModelState.IsValid)
                    {
                        addrId = _addressRepository.AddAddressSet(v, GetUserId());
                    }
                    //  method returns to standard method of given controller (may be this) to complete address setup
                    if (null != addrId)
                    {
                        return(RedirectToAction("" /*action result is empty because returnTo contains whole URL*/,
                                                returnTo, new { addressID = (Int64)addrId }));
                    }
                    return(RedirectToAction("", returnTo));
                }

                return(RedirectToAction("SelectApartament",
                                        new { id = buildingId, streetID = streetId, cityID = cityId, stateID = stateId, countryID = countryId, returnTo }));
            }
            catch (Exception e)
            {
                ExceptionMessageToViewBag(e);
                return(View("Error"));
            }
        }