Esempio n. 1
0
        public ActionResult AddAddress(AddressModel addressModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    AddressRepository   addressRepo  = new AddressRepository();
                    List <AddressModel> allAddresses = addressRepo.GetAllMatchingAddress(addressModel.Address, addressModel.ZipCode);
                    if (allAddresses.Count == 0)
                    {
                        ViewBag.Message = "\nNo Match Found.";
                    }
                    else
                    {
                        if (allAddresses.Count > 0)
                        {
                            ViewBag.Message = "\nMultiple Match Found.";
                        }
                        else
                        {
                            ViewBag.Message = "\nSingle Address Found.";
                        }
                        if (addressRepo.AddAddress(allAddresses))
                        {
                            ViewBag.Message += "\nAddress added successfully.";
                            if (addressRepo.UpdateAddress())
                            {
                                ViewBag.Message += "\nSingle address status updated.";
                            }
                            else
                            {
                                ViewBag.Message += "\nStatus is not updated for any address.";
                            }
                        }
                        else
                        {
                            ViewBag.Message += "\nFailure when adding address.";
                        }
                    }
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
        private void AddressLookup()
        {
            AddressRepository   addressRepo  = new AddressRepository();
            List <AddressModel> allAddresses = addressRepo.GetAllMatchingAddress(_addressModel.Address, _addressModel.ZipCode);

            if (allAddresses.Count == 0)
            {
                Result = "\nNo Match Found.";
            }
            else
            {
                if (allAddresses.Count > 0)
                {
                    Result = "Multiple Match Found.";
                }
                else
                {
                    Result = "Single Address Found.";
                }
                if (addressRepo.AddAddress(allAddresses))
                {
                    Result += "Address added successfully.";
                    if (addressRepo.UpdateAddress())
                    {
                        Result += "Single address status updated.";
                    }
                    else
                    {
                        Result += "Status is not updated for any address.";
                    }
                }
                else
                {
                    Result += "Failure when adding address.";
                }
            }
        }
Esempio n. 3
0
        public ActionResult Address(Address address)
        {
            var userId = User.Identity.GetUserId();

            // jeżeli nie przejdzie walidacji
            if (!ModelState.IsValid)
            {
                var vm = PrepareEditAddressVm(address, userId);
                return(View("Address", vm));
            }


            if (address.Id == 0)
            {
                _addressRepository.AddAddress(address, userId);
            }
            else
            {
                _addressRepository.UpdateAddress(address, userId);
            }


            return(RedirectToAction("Addresses", new { id = address.Id }));
        }
Esempio n. 4
0
 public void AddAddress(Address address)
 {
     repository.AddAddress(address);
 }