public async Task <ActionResult> InsertUpdateUserAddress(UserAddressModel userAddress)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var json                = JsonConvert.SerializeObject(userAddress.UserAddressObject);
                var content             = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage Res = await client.PostAsync("api/DoctorAPI/InsertUpdateUserAddress", content);

                UserAddressResponse result = new UserAddressResponse();
                if (Res.IsSuccessStatusCode)
                {
                    result.IsSuccess = true;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = Res.Content.ReadAsStringAsync().Result;
                }
                return(View("UserAddressResponse", result));
            }
        }
        /// <summary>
        /// Prepare user address model
        /// </summary>
        /// <param name="model">User address model</param>
        /// <param name="user">User</param>
        /// <param name="address">Address</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>User address model</returns>
        public virtual UserAddressModel PrepareUserAddressModel(UserAddressModel model,
                                                                User user, Address address, bool excludeProperties = false)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (address != null)
            {
                //fill in model values from the entity
                model = model ?? new UserAddressModel();

                //whether to fill in some of properties
                if (!excludeProperties)
                {
                    model.Address = address.ToModel(model.Address);
                }
            }

            model.UserId = user.Id;

            //prepare address model
            PrepareAddressModel(model.Address, address);

            return(model);
        }
Beispiel #3
0
        public ActionResult CreateOrUpdate([FromRoute] int systemUserId, [FromBody] AddressViewModel model)
        {
            var address = new UserAddressModel()
            {
                GoogleLocation   = model.GoogleLocation,
                Latitude         = model.Latitude.ToString(),
                Longitude        = model.Longitude.ToString(),
                PhysicalCity     = model.PhysicalCity,
                PhysicalCountry  = model.PhysicalCountry,
                PhysicalLine1    = model.PhysicalLine1,
                PhysicalLine2    = model.PhysicalLine2,
                PhysicalLine3    = model.PhysicalLine3,
                PhysicalPostCode = model.PhysicalPostCode,
                PhysicalState    = model.PhysicalState,
                PhysicalSuburb   = model.PhysicalSuburb,
                PostalCity       = model.PostalCity,
                PostalCountry    = model.PostalCountry,
                PostalLine1      = model.PostalLine1,
                PostalLine2      = model.PostalLine2,
                PostalLine3      = model.PostalLine3,
                PostalPostCode   = model.PostalPostCode,
                PostalState      = model.PostalState,
                PostalSuburb     = model.PostalSuburb,
                SystemUserId     = systemUserId
            };

            _addressService.Update(address);
            return(Ok(MessageHelper.Success("The address has been updated.")));
        }
Beispiel #4
0
        private void AddPaymentToCart(ICart cart, Guid paymentMethodGuid, UserAddressModel billingAddress)
        {
            var market = _marketService.GetMarket(cart.MarketId);

            var paymentMethod = _paymentManagerFacade
                                .GetPaymentMethodsByMarket(market.MarketId.Value, market.DefaultLanguage.TwoLetterISOLanguageName)
                                .PaymentMethod
                                .FindByPaymentMethodId(paymentMethodGuid);

            var paymentMethodImplementation = _paymentMethods.SingleOrDefault(x => x.PaymentMethodId == paymentMethod.PaymentMethodId);

            if (paymentMethodImplementation != null)
            {
                var payment = paymentMethodImplementation.CreatePayment(cart.GetTotal().Amount, cart);

                var orderBillingAddress = cart.CreateOrderAddress("BillingAddressId");
                orderBillingAddress.City               = billingAddress.City;
                orderBillingAddress.CountryCode        = billingAddress.CountryId;
                orderBillingAddress.DaytimePhoneNumber = billingAddress.Telephone;
                orderBillingAddress.FirstName          = billingAddress.Firstname;
                orderBillingAddress.LastName           = billingAddress.Lastname;
                orderBillingAddress.PostalCode         = billingAddress.Postcode;
                orderBillingAddress.Line1              = string.Join(", ", billingAddress.Street);

                payment.BillingAddress = orderBillingAddress;
                cart.AddPayment(payment);
            }
        }
Beispiel #5
0
        public IActionResult SearchDonations(string searchQ)
        {
            HomeViewModel home_model = new HomeViewModel();

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            UserAddressModel user_address = _userAddressContext.UserAddress.Select(addrs => addrs).Where(add => add.Id.Equals(userId)).FirstOrDefault();

            if (user_address != null)
            {
                home_model.HomeAddress = user_address.StreetAddress + " " +
                                         user_address.StreetAddress2 + " " +
                                         user_address.City + ", " +
                                         user_address.State + " " +
                                         user_address.Zip;
            }

            List <DonationsModel> all_donations = _donationsContext.
                                                  Donations.
                                                  Select(dnts => dnts).
                                                  Where(dnt => dnt.Status.Equals("Available") && (dnt.Description.Contains(searchQ))).
                                                  ToList();
            List <string>            donors = new List <string>();
            Dictionary <string, int> donor_donations_dict = new Dictionary <string, int>();
            var users = _userManager.GetUsersForClaimAsync(new Claim("UserType", "Donor")).Result;

            home_model.Donations = all_donations;

            return(View(home_model));
        }
Beispiel #6
0
        public static CustomerAddress CreateCustomerAddress(UserAddressModel addressModel, Guid userGuid)
        {
            var customerAddress = CustomerAddress.CreateInstance();

            UpdateContactAddressData(customerAddress, addressModel);
            customerAddress.ContactId = new PrimaryKeyId(userGuid);
            customerAddress.AddressId = new PrimaryKeyId(Guid.NewGuid());

            return(customerAddress);
        }
Beispiel #7
0
        public IActionResult Index()
        {
            HomeViewModel home_model = new HomeViewModel();

            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            UserAddressModel user_address = _userAddressContext.UserAddress.Select(addrs => addrs).Where(add => add.Id.Equals(userId)).FirstOrDefault();

            if (user_address != null)
            {
                home_model.HomeAddress = user_address.StreetAddress + " " +
                                         user_address.StreetAddress2 + " " +
                                         user_address.City + ", " +
                                         user_address.State + " " +
                                         user_address.Zip;
            }

            List <DonationsModel>    all_donations        = _donationsContext.Donations.Select(dnts => dnts).Where(dnt => dnt.Status.Equals("Available")).ToList();
            List <string>            donors               = new List <string>();
            Dictionary <string, int> donor_donations_dict = new Dictionary <string, int>();
            var users = _userManager.GetUsersForClaimAsync(new Claim("UserType", "Donor")).Result;

            foreach (IdentityUser user in users)
            {
                var donations_per_user = _leftRoverContext.Donations.Where(dnts => dnts.UserId.Equals(user.Id));
                if (donations_per_user != null)
                {
                    donor_donations_dict.Add(user.Id, donations_per_user.ToList().Count);
                }
            }

            var ordered = donor_donations_dict.OrderByDescending(x => x.Value);

            int start = 0;

            foreach (KeyValuePair <string, int> entry in ordered)
            {
                if (start > 5)
                {
                    break;
                }
                else
                {
                    UserInfoModel info = _userInfoContext.UserInfo.Where(ui => ui.Id.Equals(entry.Key)).FirstOrDefault();

                    donors.Add(info.OrganizationName + " with " + entry.Value + " donations.");
                }
            }

            home_model.Donations  = all_donations;
            home_model.Top5Donors = donors;

            return(View(home_model));
        }
        public async Task <ActionResult> UserAddress(int doctorId, int?userAddressId, int userId)
        {
            var model = new UserAddressModel
            {
                UserId = userId
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage Res = await client.GetAsync("api/SignUpAPI/GetCountries?isActive=true");

                model.CountryList = JsonConvert.DeserializeObject <List <Country> >(Res.Content.ReadAsStringAsync().Result);

                Res = await client.GetAsync("api/SignUpAPI/GetAddressTypes?isActive=true");

                model.AddressTypes = JsonConvert.DeserializeObject <List <AddressType> >(Res.Content.ReadAsStringAsync().Result);
                if (userAddressId.HasValue)
                {
                    Res = await client.GetAsync("api/DoctorAPI/GetUserAddressList?userId=" + doctorId.ToString()
                                                + "&addressId=" + userAddressId.Value.ToString());

                    var userAddressResponse = JsonConvert.DeserializeObject <UserAddressResponse>(Res.Content.ReadAsStringAsync().Result);
                    if (userAddressResponse.UserAddressList != null &&
                        userAddressResponse.UserAddressList.Count() != 0)
                    {
                        model.UserAddressObject            = userAddressResponse.UserAddressList.First();
                        model.UserAddressObject.ModifiedBy = userId;
                        Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.UserAddressObject.CountryId + "&stateId=");

                        model.StateList = JsonConvert.DeserializeObject <List <StateMaster> >(Res.Content.ReadAsStringAsync().Result);
                    }
                }
                else
                {
                    if (model.CountryList != null && model.CountryList.Count() != 0)
                    {
                        Res = await client.GetAsync("api/DoctorAPI/GetStates?isActive=true&countryId=" + model.CountryList.First().Id + "&stateId=");

                        model.StateList = JsonConvert.DeserializeObject <List <StateMaster> >(Res.Content.ReadAsStringAsync().Result);
                    }
                    model.UserAddressObject = new UserAddress
                    {
                        UserId  = doctorId,
                        AddedBy = userId
                    };
                }
            }
            return(View("UserAddress", model));
        }
Beispiel #9
0
        private void AddShippingAddress(ICart cart, UserAddressModel shippingAddress)
        {
            var orderShippingAddress = cart.CreateOrderAddress("ShippingAddressId");

            orderShippingAddress.City               = shippingAddress.City;
            orderShippingAddress.CountryCode        = shippingAddress.CountryId;
            orderShippingAddress.DaytimePhoneNumber = shippingAddress.Telephone;
            orderShippingAddress.FirstName          = shippingAddress.Firstname;
            orderShippingAddress.LastName           = shippingAddress.Lastname;
            orderShippingAddress.PostalCode         = shippingAddress.Postcode;
            orderShippingAddress.Line1              = string.Join(", ", shippingAddress.Street);

            cart.GetFirstShipment().ShippingAddress = orderShippingAddress;
        }
Beispiel #10
0
        public void UpdateShippingAddress(Guid contactId, UserAddressModel shippingAddress)
        {
            var cart = GetCart(contactId);
            var orderShippingAddress = cart.CreateOrderAddress("ShippingAddressId");

            orderShippingAddress.CountryCode        = shippingAddress.CountryId;
            orderShippingAddress.City               = shippingAddress.City;
            orderShippingAddress.DaytimePhoneNumber = shippingAddress.Telephone;
            orderShippingAddress.FirstName          = shippingAddress.Firstname;
            orderShippingAddress.LastName           = shippingAddress.Lastname;
            orderShippingAddress.PostalCode         = shippingAddress.Postcode;
            orderShippingAddress.Line1              = string.Join(", ", shippingAddress.Street);

            cart.GetFirstShipment().ShippingAddress = orderShippingAddress;
            _orderRepository.Save(cart);
        }
Beispiel #11
0
 public static UserAddressModel CreateUserAddress(UserAddressModel addressModel)
 {
     using (var _context = new bbbsDbContext())
     {
         var newAddress = _context.Add(new UserAddress
         {
             City        = addressModel.City,
             Zip         = addressModel.Zip,
             StreetLine1 = addressModel.StreetLine1,
             StreetLine2 = addressModel.StreetLine2,
             State       = addressModel.State
         });
         _context.SaveChanges();
         addressModel.Id = newAddress.Entity.Id;
         return(addressModel);
     }
 }
        public virtual ActionResult ChangeAddressPartial()
        {
            var user = _userManager.FindById(User.Identity.GetUserId <int>());

            var model = new UserAddressModel
            {
                Imie        = user.Name ?? "Nie podano",
                Nazwisko    = user.LastName ?? "Nie podano",
                Ulica       = user.Street ?? "Nie podano",
                Telefon     = user.PhoneNumber ?? "Nie podano",
                KodPocztowy = user.PostalCode ?? "Nie podano",
                Miasto      = user.City ?? "Nie podano",
                Numer       = user.Number ?? "Nie podano"
            };

            return(PartialView("_ChangeAddressPartial", model));
        }
Beispiel #13
0
        public static UserAddressModel UpdateUserAddress(UserAddressModel userAddressModel)
        {
            using (var _context = new bbbsDbContext())
            {
                var existingUserAddress = _context.UserAddresses.FirstOrDefault(x => x.Id == userAddressModel.Id);

                if (existingUserAddress != null)
                {
                    existingUserAddress.StreetLine1 = userAddressModel.StreetLine1;
                    existingUserAddress.StreetLine2 = userAddressModel.StreetLine2;
                    existingUserAddress.City        = userAddressModel.City;
                    existingUserAddress.State       = userAddressModel.State;
                    existingUserAddress.Zip         = userAddressModel.Zip;
                    _context.SaveChanges();
                    return(userAddressModel);
                }
            }
            return(null);
        }
 public virtual ActionResult ChangeAddressPartial(UserAddressModel model, Cart shoppingCart)
 {
     if (ModelState.IsValid)
     {
         shoppingCart.Email            = User.Identity.Name;
         shoppingCart.UserAddressModel = new CartAddressModel
         {
             Imie        = model.Imie,
             KodPocztowy = model.KodPocztowy,
             Miasto      = model.Miasto,
             Nazwisko    = model.Nazwisko,
             Numer       = model.Numer,
             Telefon     = model.Telefon,
             Ulica       = model.Ulica
         };
         return(JavaScript(string.Format("document.location = '{0}';", Url.Action(MVC.Zamowienie.Podsumowanie()))));
     }
     return(PartialView("_ChangeAddressPartial", model));
 }
        public ActionResult UserCheckOut(UserAddressModel userAddressModel)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.UserAddress = GetAllUserAddress(Convert.ToInt32(Session["UserId"].ToString()));
                return(View(userAddressModel));
            }
            else
            {
                userAddressModel.UserId = Convert.ToInt32(Session["UserId"].ToString());
                UserAddressDal      userAddressDal  = new UserAddressDal();
                List <ItemGroupDto> lstItemGroupDto = itemGroupDal.GetAndEditItemGroup(0, 1);
                ViewBag.ItemGroups = lstItemGroupDto;
                UserAddressDto userAddressDto = new UserAddressDto();
                userAddressDto.AddressId = userAddressModel.AddressId;
                userAddressDto.UserId    = userAddressModel.UserId;
                userAddressDto.Name      = userAddressModel.Name;
                userAddressDto.MobileNo  = userAddressModel.MobileNo;
                userAddressDto.Pincode   = userAddressModel.Pincode;
                userAddressDto.Address   = userAddressModel.Address;
                userAddressDto.Locality  = userAddressModel.Locality;
                userAddressDto.City      = userAddressModel.City;
                userAddressDto.State     = userAddressModel.State;
                userAddressDto.Country   = userAddressModel.Country;
                userAddressDto.IsActive  = 1;
                int i = userAddressDal.SaveAndUpdateUserAddress(userAddressDto);
                if (i > 0)
                {
                    ViewBag.successText = "Successfully Address Saved";
                }
                else
                {
                    ViewBag.failureText = "Your Address is not saved successfully in our Website. Please Try after Sometime ";
                }

                ModelState.Clear();
                ViewBag.UserAddress = GetAllUserAddress(Convert.ToInt32(Session["UserId"].ToString()));
                return(View());
            }
        }
Beispiel #16
0
        public static void UpdateContactAddressData(CustomerAddress customerAddress, UserAddressModel updatedAddressModel)
        {
            customerAddress.City               = updatedAddressModel.City;
            customerAddress.RegionName         = updatedAddressModel.Region?.Region;
            customerAddress.FirstName          = updatedAddressModel.Firstname;
            customerAddress.LastName           = updatedAddressModel.Lastname;
            customerAddress.Line1              = updatedAddressModel.Street?[0];
            customerAddress.Line2              = updatedAddressModel.Street?[1];
            customerAddress.CountryCode        = updatedAddressModel.CountryId;
            customerAddress.PostalCode         = updatedAddressModel.Postcode;
            customerAddress.DaytimePhoneNumber = updatedAddressModel.Telephone;

            if (updatedAddressModel.DefaultBilling)
            {
                customerAddress.AddressType |= CustomerAddressTypeEnum.Billing;
            }

            if (updatedAddressModel.DefaultShipping)
            {
                customerAddress.AddressType |= CustomerAddressTypeEnum.Shipping;
            }
        }
Beispiel #17
0
        public IActionResult UpdateInfo(UpdateInfoViewModel model)
        {
            // no error initially
            model.UpdateStatus = -1;
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var user   = _userManager.FindByIdAsync(userId);

            // try updating the database
            try
            {
                UserAddressModel address = _userAddressContext.UserAddress.Select(addrs => addrs).Where(add => add.Id.Equals(userId)).FirstOrDefault();
                UserInfoModel    info    = _userInfoContext.UserInfo.Select(infos => infos).Where(info => info.Id.Equals(userId)).FirstOrDefault();

                address.StreetAddress  = model.StreetAddress;
                address.StreetAddress2 = model.StreetAddress2;
                address.City           = model.City;
                address.State          = model.State;
                address.Zip            = model.Zip;

                info.OrganizationName = model.OrganizationName;
                info.FirstName        = model.FirstName;
                info.LastName         = model.LastName;
                info.PhoneNumber      = model.PhoneNumber;
                info.TaxID            = model.TaxID;

                _userAddressContext.SaveChanges();
                _userInfoContext.SaveChanges();

                model.UpdateStatus = 0;
            }
            catch (Exception e)
            {
                model.UpdateStatus = 1;
            }

            return(View("MyProfile", model));
        }
Beispiel #18
0
        public IActionResult MyProfile()
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            UserAddressModel address = _userAddressContext.UserAddress.Select(addrs => addrs).Where(add => add.Id.Equals(userId)).FirstOrDefault();
            UserInfoModel    info    = _userInfoContext.UserInfo.Select(infos => infos).Where(info => info.Id.Equals(userId)).FirstOrDefault();

            UpdateInfoViewModel model = new UpdateInfoViewModel
            {
                OrganizationName = info.OrganizationName,
                FirstName        = info.FirstName,
                LastName         = info.LastName,
                PhoneNumber      = info.PhoneNumber,
                StreetAddress    = address.StreetAddress,
                StreetAddress2   = address.StreetAddress2,
                City             = address.City,
                State            = address.State,
                Zip   = address.Zip,
                TaxID = info.TaxID
            };

            // no error initially
            model.UpdateStatus = -1;
            return(View(model));
        }
        public void Update(UserAddressModel model)
        {
            var user = _systemUserRepository.GetFirstOrDefault(predicate: a => a.SystemUserId == model.SystemUserId, include: a => a.Include(b => b.Business));

            if (user == null)
            {
                throw new ApplicationException("System user id is invalid");
            }

            var business = user.Business;

            business.PhysicalCity     = model.PhysicalCity;
            business.PhysicalCountry  = model.PhysicalCountry;
            business.PhysicalLine1    = model.PhysicalLine1;
            business.PhysicalLine2    = model.PhysicalLine2;
            business.PhysicalLine3    = model.PhysicalLine3;
            business.PhysicalPostCode = model.PhysicalPostCode;
            business.PhysicalState    = model.PhysicalState;
            business.PhysicalSuburb   = model.PhysicalSuburb;

            business.PostalCity     = model.PostalCity;
            business.PostalCountry  = model.PostalCountry;
            business.PostalLine1    = model.PostalLine1;
            business.PostalLine2    = model.PostalLine2;
            business.PostalLine3    = model.PostalLine3;
            business.PostalPostCode = model.PostalPostCode;
            business.PostalState    = model.PostalState;
            business.PostalSuburb   = model.PostalSuburb;

            business.LocationLong   = model.Longitude;
            business.LocationLat    = model.Latitude;
            business.GoogleLocation = model.GoogleLocation;

            _businessRepository.Update(business);
            _unitOfWork.SaveChanges();
        }
Beispiel #20
0
        private static UserAddressModel CreateUserAddress(CustomerAddress address, InvoiceInformation invoiceInformation, bool isDefaultBilling, bool isDefaultShipping)
        {
            var userAddressModel = new UserAddressModel();

            var street = new List <string>(2);

            if (address.Line1 != null)
            {
                street.Add(address.Line1);
            }

            if (address.Line2 != null)
            {
                street.Add(address.Line2);
            }

            userAddressModel.Id              = address.AddressId.ToString();
            userAddressModel.CustomerId      = address.ContactId.ToString();
            userAddressModel.Firstname       = address.FirstName;
            userAddressModel.Lastname        = address.LastName;
            userAddressModel.DefaultShipping = isDefaultShipping;
            userAddressModel.DefaultBilling  = isDefaultBilling;
            userAddressModel.Region          = new UserAddressModel.RegionModel
            {
                Region = address.RegionName
            };
            userAddressModel.City      = address.City;
            userAddressModel.CountryId = address.CountryCode;
            userAddressModel.Postcode  = address.PostalCode;
            userAddressModel.Telephone = address.DaytimePhoneNumber;
            userAddressModel.Street    = street;
            userAddressModel.Company   = invoiceInformation?.Company;
            userAddressModel.VatId     = invoiceInformation?.VatId;

            return(userAddressModel);
        }
 public static UserAddressModel CreateUserAddress(UserAddressModel addressModel)
 {
     return(AddressRepository.CreateUserAddress(addressModel));
 }
Beispiel #22
0
        public ActionResult GiveAway()
        {
            LoadCountries();

            var model = new UserAddressModel();

            var uadress = new UserAddress();

            model.AddressLine1 = uadress.AddressLine1;
            model.AddressLine2 = uadress.AddressLine2;
            model.AddressLine3 = uadress.AddressLine3;
            model.City = uadress.City;
            model.Country = uadress.CountryISO;
            model.FirstName = uadress.FirstName;
            model.LastName = uadress.LastName;
            model.PostalCode = uadress.PostalCode;
            model.RegionState = uadress.Region;

            return View(model);
        }
Beispiel #23
0
        public async Task <UserAddressModel> UpdateUserAddress(UserAddressModel userAddressModel)
        {
            var result = await _httpClient.PutJsonAsync <ResultModel>("/api/services/app/UserAddressService/Update", userAddressModel);

            return(JsonConvert.DeserializeObject <UserAddressModel>(result.Result.ToString()));
        }
Beispiel #24
0
        public ActionResult GiveAway(UserAddressModel model)
        {
            LoadCountries();

            var uadress = new UserAddress();

            TryUpdateModel(model);

            if (ModelState.IsValid)
            {
                uadress.AddressLine1 = model.AddressLine1;
                uadress.AddressLine2 = model.AddressLine2;
                uadress.AddressLine3 = model.AddressLine3;
                uadress.City = model.City;
                uadress.CountryISO = model.Country;
                uadress.FirstName = model.FirstName;
                uadress.LastName = model.LastName;
                uadress.PostalCode = model.PostalCode;
                uadress.Region = model.RegionState;

                if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U';

                uadress.Set();

                ViewBag.IsSuccess = true;

                return View(model);
            }

            return View(model);
        }
 public UserAddressModel CreateUserAddress(UserAddressModel userAddressModel)
 {
     return(AddressService.CreateUserAddress(userAddressModel));
 }
Beispiel #26
0
        public IEnumerable <ShippingMethod> GetShippingMethods(Guid contactId, UserAddressModel address)
        {
            var cart = GetCart(contactId);

            return(cart.GetFirstForm().Shipments.SelectMany(shipment => GetShippingMethods(cart.MarketId, cart.Currency, shipment)));
        }
 public static UserAddressModel UpdateUserAddress(UserAddressModel userAddressModel)
 {
     return(AddressRepository.UpdateUserAddress(userAddressModel));
 }
 public UserModel()
 {
     UserAddress = new UserAddressModel();
 }
Beispiel #29
0
        public ActionResult UserAddress(UserAddressModel model)
        {
            LoadCountries();

            if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey));

            _uad = new UserAccountDetail();
            _uad.GetUserAccountDeailForUser(_ua.UserAccountID);

            var uadress = new UserAddress();

            uadress.GetUserAddress(_ua.UserAccountID);

            TryUpdateModel(model);

            if (ModelState.IsValid)
            {
                uadress.AddressLine1 = model.AddressLine1;
                uadress.AddressLine2 = model.AddressLine2;
                uadress.AddressLine3 = model.AddressLine3;
                uadress.City = model.City;
                uadress.CountryISO = model.Country;
                uadress.FirstName = model.FirstName;
                uadress.LastName = model.LastName;
                uadress.PostalCode = model.PostalCode;
                uadress.Region = model.RegionState;
                uadress.UserAccountID = _ua.UserAccountID;
                //  uadress.Choice1 = "||" + Request.Form["sex"] + "|" + Request.Form["size"];

                if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U';

                ViewBag.ProfileUpdated = uadress.Set();

                Response.Redirect("/account/home");
            }

            return View(model);
        }
Beispiel #30
0
        public ActionResult UserAddress()
        {
            LoadCountries();

            if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey));

            _uad = new UserAccountDetail();
            _uad.GetUserAccountDeailForUser(_ua.UserAccountID);

            var model = new UserAddressModel();

            var uadress = new UserAddress();

            uadress.GetUserAddress(_ua.UserAccountID);

            if (GeneralConfigs.IsGiveAway && uadress.UserAddressID > 0) return View("NotAllowed");

            if (uadress.UserAddressID == 0)
            {
                model.PostalCode = _uad.PostalCode;
                model.Country = _uad.Country;
            }
            else
            {
                model.AddressLine1 = uadress.AddressLine1;
                model.AddressLine2 = uadress.AddressLine2;
                model.AddressLine3 = uadress.AddressLine3;
                model.City = uadress.City;
                model.Country = uadress.CountryISO;
                model.FirstName = uadress.FirstName;
                model.LastName = uadress.LastName;
                model.PostalCode = uadress.PostalCode;
                model.RegionState = uadress.Region;
            }

            return View(model);
        }
Beispiel #31
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new IdentityUser
                {
                    UserName = model.Email,
                    Email    = model.Email,
                };

                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // try to add the claim
                    try
                    {
                        await _userManager.AddClaimAsync(user, new Claim("UserType", model.DonorRecipient));
                    }
                    catch (Exception e)
                    {
                    }

                    // try to add the address
                    UserAddressModel address = new UserAddressModel
                    {
                        Id             = user.Id,
                        StreetAddress  = model.StreetAddress,
                        StreetAddress2 = model.StreetAddress2,
                        City           = model.City,
                        State          = model.State,
                        Zip            = model.Zip
                    };

                    try
                    {
                        await _userAddressContext.UserAddress.AddAsync(address);

                        await _userAddressContext.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                    }

                    // try to add the user info
                    UserInfoModel info = new UserInfoModel
                    {
                        Id               = user.Id,
                        FirstName        = model.FirstName,
                        LastName         = model.LastName,
                        PhoneNumber      = model.PhoneNumber,
                        TaxID            = model.TaxID,
                        OrganizationName = model.OrganizationName
                    };

                    try
                    {
                        await _userInfoContext.UserInfo.AddAsync(info);

                        await _userInfoContext.SaveChangesAsync();
                    }
                    catch (Exception e)
                    {
                    }

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(RedirectToAction("Index", "Home"));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }

                ModelState.AddModelError(string.Empty, "Invalid Login Attempt");
            }
            return(View(model));
        }