/// <summary>
        /// 
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="form"></param>
        /// <returns></returns>
        public ActionResult AdressInfo(EditProfileViewModel vm, FormCollection form)
        {
            // grab the form's dropdown lists selected value.
            var homeCountry = Int32.Parse(form["homeCountry"]);
            var homeProvince = Int32.Parse(form["homeProvince"]);
            var homeState = Int32.Parse(form["homeState"]);
            var shippingCountry = Int32.Parse(form["shippingCountry"]);
            var shippingProvince = Int32.Parse(form["shippingProvince"]);
            var shippingState = Int32.Parse(form["shippingState"]);

            // check which country is selected. If shipping and home addresses are the same Country,
            // some of the form collection attributes will bu null/zero.
            int homeCountryId = homeCountry;
            int homeProvinceOrState = homeCountryId == 1 ? homeProvince : homeState;
            int shippingProvinceOrState = shippingCountry == 1 ? shippingProvince : shippingState;

            var homeAddress = new Address()
            {
                Street1 = form["EditMembersAddressViewModel.HomeAddress.Street1"],
                Street2 = form["EditMembersAddressViewModel.HomeAddress.Street2"],
                City = form["EditMembersAddressViewModel.HomeAddress.City"],
                PostalZipCode = form["EditMembersAddressViewModel.HomeAddress.PostalZipCode"].Replace(",", ""),
                ProvinceStateId = homeProvinceOrState,
                CountryId = homeCountry
            };

            var shippingAddress = new Address()
                {
                    Street1 = form["EditMembersAddressViewModel.ShippingAddress.Street1"],
                    Street2 = form["EditMembersAddressViewModel.ShippingAddress.Street2"],
                    City = form["EditMembersAddressViewModel.ShippingAddress.City"],
                    PostalZipCode = form["EditMembersAddressViewModel.ShippingAddress.PostalZipCode"].Replace(",", ""),
                    ProvinceStateId = shippingProvinceOrState,
                    CountryId = shippingCountry
                };

            using (db)
            {
                try
                {
                    Member member = db.Members.FirstOrDefault(m => m.DisplayName == User.Identity.Name);
                    member.MemberDetails.HomeAddress = homeAddress;
                    member.MemberDetails.ShippingAddress = shippingAddress;
                    member.MemberDetails.HomeAddress.State = State.Added;
                    member.MemberDetails.ShippingAddress.State = State.Added;
                    member.MemberDetails.State = State.Modified;

                    db.MemberDetails.AddOrUpdate(member.MemberDetails);
                    db.SaveChanges();
                }

                catch (Exception e)
                {
                    TempData["message"] = "Error: " + e.InnerException;
                }
            }

            return null;
        }
        public ActionResult EnterShippingAddress(ShippingAddressViewModel vm, FormCollection form)
        {
            // grab the form's dropdown lists selected value.
            var country = Int32.Parse(form["shippingCountry"]);
            var province = Int32.Parse(form["shippingProvince"]);
            var state = Int32.Parse(form["shippingState"]);

            int countryId = country;
            int shippingProvinceOrState = countryId == 1 ? province : state;

            var shippingAddress = new Address()
            {
                Street1 = vm.ShippingAddress.Street1,
                Street2 = vm.ShippingAddress.Street1,
                City = vm.ShippingAddress.City,
                ProvinceStateId = shippingProvinceOrState,
                PostalZipCode = vm.ShippingAddress.PostalZipCode,
                CountryId = country
            };

            // get the member details so we can attach the address ...
            var member = UoW.Members.GetAll().FirstOrDefault(m => m.DisplayName == User.Identity.Name);

            if (ModelState.IsValid)
            {
                try
                {
                    member.MemberDetails.FirstName = vm.FirstName;
                    member.MemberDetails.LastName = vm.LastName;
                    member.MemberDetails.ShippingAddress = shippingAddress;
                    member.MemberDetails.ShippingAddress.State = State.Added;
                    member.MemberDetails.State = State.Modified;
                    UoW.MemberDetails.Update(member.MemberDetails);
                    UoW.SaveChanges();
                }
                catch (Exception e)
                {
                    TempData["message"] = "Error: " + e.InnerException;
                }
            }

            return RedirectToAction("AddressAndPayment","Checkout");
        }
        public ActionResult Create(CreateEventViewModel model, FormCollection form)
        {
            ViewBag.Country = new SelectList(UoW.Countries.GetAll().ToList(), "CountryId", "Name");
            ViewBag.Province = new SelectList(UoW.ProvinceStates.GetAll().OrderBy(p => p.ProvinceStateId).Take(13), "ProvinceStateId", "Name");
            ViewBag.State = new SelectList(UoW.ProvinceStates.GetAll().OrderBy(p => p.ProvinceStateId).Skip(13), "ProvinceStateId", "Name");

            // grab the form's dropdown lists selected value.
            var Country = Int32.Parse(form["Country"]);
            var Province = Int32.Parse(form["Province"]);
            var State = Int32.Parse(form["State"]);

            // check which country is selected. If shipping and home addresses are the same Country,
            // some of the form collection attributes will bu null/zero.
            int CountryId = Country;
            int ProvinceOrState = CountryId == 1 ? Province : State;

            var Address = new Address()
            {
                Street1 = model.Address.Street1,
                Street2 = model.Address.Street2,
                City = model.Address.City,
                PostalZipCode = model.Address.PostalZipCode,
                ProvinceStateId = ProvinceOrState,
                CountryId = Country
            };
            var Event = new Models.Event()
            {
                Address = Address,
                Date = model.Date,
                Name = model.Name,
                EventDetails = model.EventDetails
            };

            if (ModelState.IsValid)
            {

                try
                {
                    db.Events.Add(Event);
                    db.SaveChanges();
                    TempData["toast"] = "<script> $(document).ready(function () {" +
                       "toastr.options = { 'positionClass': 'toast-bottom-right' };" +
                       "toastr.success('Event was created successfully!');});</script>";
                    return RedirectToAction("EmployeeEventsIndex", "Events");
                }
                catch (Exception)
                {
                    TempData["toast"] = "<script> $(document).ready(function () {" +
                      "toastr.options = { 'positionClass': 'toast-bottom-right' };" +
                      "toastr.error('Error saving the event. Please try again.');});</script>";
                    return View("Create", model);
                }
            }

            return View("Create", model);
        }