コード例 #1
0
        public Guid AddAddress(Guid userID, AddressDTO addressDTO)
        {
            Guid    id        = Guid.NewGuid();
            Guid    mappingID = Guid.NewGuid();
            Address address   = new Address {
                ID = id, AddressLine1 = addressDTO.AddressLine1, AddressLine2 = addressDTO.AddressLine2, City = addressDTO.City, Pin = addressDTO.PIN, State = addressDTO.State, Country = addressDTO.Country
            };

            try {
                FutureKartContext.Addresses.Add(address);
            }
            catch (Exception ex)
            {
                throw new AddAddressException("Unknown exception occured " + ex);
            }
            UserAddressMapping userAddressMapping = new UserAddressMapping {
                ID = mappingID, AddressID = id, UserID = userID
            };

            try {
                FutureKartContext.UserAddressMappings.Add(userAddressMapping);
            }
            catch (Exception ex)
            {
                throw new AddAddressException("Unknown exception occured " + ex);
            }
            FutureKartContext.SaveChanges();
            return(id);
        }
コード例 #2
0
        /// <summary>
        /// add address
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="newAddress"></param>
        /// <returns>true is added</returns>
        public bool AddAddress(Guid UserID, AddressDTO newAddress)
        {
            newAddress.ID = Guid.NewGuid();
            Address            newAddres          = AddressAdded.Map <AddressDTO, Address>(newAddress);
            UserAddressMapping userAddressMapping = new UserAddressMapping();

            userAddressMapping.ID        = Guid.NewGuid();
            userAddressMapping.UserID    = UserID;
            userAddressMapping.AddressID = newAddress.ID;

            dbContext.Addresses.Add(newAddres);
            dbContext.UserAddressMappings.Add(userAddressMapping);
            dbContext.SaveChanges();
            return(true);
        }
コード例 #3
0
        public Guid AddAddress(Guid UserID, AddressDTO addressDTO)
        {
            Guid    id        = Guid.NewGuid();
            Guid    mappingID = Guid.NewGuid();
            Address address   = new Address {
                ID = id, AddressLine1 = addressDTO.AddressLine1, AddressLine2 = addressDTO.AddressLine2, City = addressDTO.City, Pin = addressDTO.Pin, State = addressDTO.State, Country = addressDTO.Country
            };

            shoppingCartEntities.Addresses.Add(address);
            UserAddressMapping userAddressMapping = new UserAddressMapping {
                ID = mappingID, AddressID = id, UserID = UserID
            };

            shoppingCartEntities.UserAddressMappings.Add(userAddressMapping);
            shoppingCartEntities.SaveChanges();
            return(id);
        }