public PartialViewResult ClientAddress(EntertainmentAddressViewModel model)
        {
            if (ModelState.IsValid)
            {
                var existingEntertainmentAddress = _repositoryTicketServices.GetEntertainmentAddressByUsername(User.Identity.Name);

                if (existingEntertainmentAddress != null)
                {
                    existingEntertainmentAddress.AddressLine1 = model.AddressLine1;
                    existingEntertainmentAddress.AddressLine2 = model.AddressLine2;
                    existingEntertainmentAddress.Town         = model.Town;
                    existingEntertainmentAddress.Country      = model.Country;
                    existingEntertainmentAddress.PostCode     = model.PostCode;

                    _repositoryTicketServices.UpdateEntertainmentAddressByUsername(User.Identity.Name, existingEntertainmentAddress);
                }
                else
                {
                    var newEntertainmentAddress = new EntertainmentAddress
                    {
                        AddressLine1 = model.AddressLine1,
                        AddressLine2 = model.AddressLine2,
                        Town         = model.Town,
                        PostCode     = model.PostCode,
                        Country      = model.Country
                    };

                    _repositoryTicketServices.AddNewClientAddress(User.Identity.Name, newEntertainmentAddress);
                }
                return(PartialView("_PatialSuccess"));
            }
            return(PartialView(model));
        }
Ejemplo n.º 2
0
        public bool AddNewClientAddress(string username, EntertainmentAddress EntertainmentAddress)
        {
            try
            {
                var user = GetUserByName(username);
                EntertainmentAddress.UserId = user.UserId;

                _EntertainmentAddressRepository.Add(EntertainmentAddress);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        public PartialViewResult ClientAddress()
        {
            var EntertainmentAddress = _repositoryTicketServices.GetEntertainmentAddressByUsername(User.Identity.Name);

            if (EntertainmentAddress == null)
            {
                EntertainmentAddress = new EntertainmentAddress();
            }
            var model = new EntertainmentAddressViewModel
            {
                AddressLine1 = EntertainmentAddress.AddressLine1,
                AddressLine2 = EntertainmentAddress.AddressLine2,
                Town         = EntertainmentAddress.Town,
                PostCode     = EntertainmentAddress.PostCode,
                Country      = EntertainmentAddress.Country
            };

            return(PartialView("ClientAddress", model));
        }
Ejemplo n.º 4
0
        public bool UpdateEntertainmentAddressByUsername(string username, EntertainmentAddress EntertainmentAddress)
        {
            try
            {
                var user = GetUserByName(username);
                var dbEntertainmentAddress = GetEntertainmentAddressByUsername(username);

                dbEntertainmentAddress.AddressLine1 = EntertainmentAddress.AddressLine1;
                dbEntertainmentAddress.AddressLine2 = EntertainmentAddress.AddressLine2;
                dbEntertainmentAddress.Town         = EntertainmentAddress.Town;
                dbEntertainmentAddress.PostCode     = EntertainmentAddress.PostCode;
                dbEntertainmentAddress.Country      = EntertainmentAddress.Country;
                dbEntertainmentAddress.UserId       = user.UserId;
                _EntertainmentAddressRepository.Update(dbEntertainmentAddress);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }