Exemplo n.º 1
0
        public Zipcode[] getCitiesInState(string stateAbbr)
        {
            if (string.IsNullOrEmpty(stateAbbr))
            {
                throw new ArgumentNullException("Must supply a state abbreviation");
            }
            string statement = "SELECT ZIPCode,CityName,StateName,StateAbbr FROM ZIPCodes " +
                "WHERE StateAbbr = @STATEABBR " +
                "AND CityType<>'N' AND ZipType<>'U' AND ZipType<>'M' ORDER BY CityName,ZIPCode;";
            SqlCommand command = new SqlCommand(statement);
            SqlParameter stateAbbrParam = new SqlParameter("@STATEABBR", SqlDbType.NVarChar, 2);
            stateAbbrParam.Value = stateAbbr.ToUpper();
            command.Parameters.Add(stateAbbrParam);

            DataTable results = query(command);
            if (results == null || results.Rows == null || results.Rows.Count == 0)
            {
                return null;
            }

            Zipcode[] zips = new Zipcode[results.Rows.Count];
            for (int i = 0; i < results.Rows.Count; i++)
            {
                zips[i] = new Zipcode(
                    results.Rows[i]["ZIPCode"] as string,
                    results.Rows[i]["CityName"] as string,
                    results.Rows[i]["StateName"] as string,
                    results.Rows[i]["StateAbbr"] as string);
            }

            return zips;
        }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        id = int.Parse(Request.QueryString["id"]);
        using (CCSEntities db = new CCSEntities())
        {
            a = (from ag in db.Agencies where ag.AgencyID == id select ag).First();
            //Update simple fields
            if(txtAgencyName.Text != "")
                a.AgencyName = txtAgencyName.Text;
            if (txtStreet1.Text != "")
                a.Address.StreetAddress1 = txtStreet1.Text;
            if (txtStreet2.Text != "")
                a.Address.StreetAddress2 = txtStreet2.Text;
            a.Address.StateID = (short)ddlState.SelectedIndex;

            string zip = txtZip.Text;
            string city = txtCity.Text;

            //does new zip already exist?
            if ((from z in db.Zipcodes where z.ZipCode1 == zip select z).Count() > 0)
            {
                //zip already exists, use existing zip
                a.Address.ZipID = (from z in db.Zipcodes where z.ZipCode1 == zip select z.ZipID).First();
            }
            else
            {
                //create new zip
                Zipcode z = new Zipcode();
                z.ZipCode1 = zip;
                db.Zipcodes.Add(z);
                a.Address.Zipcode = z;
            }

            //Does new city already exist?
            if ((from c in db.Cities where c.CityName == city select c).Count() > 0)
            {
                //zip already exists, use existing zip
                a.Address.City = (from c in db.Cities where c.CityName == city select c).First();
            }
            else
            {
                //create new zip
                City c = new City();
                c.CityName = city;
                db.Cities.Add(c);
                a.Address.City = c;
            }
            db.SaveChanges();
            saved.Visible = true;

        }
    }
Exemplo n.º 3
0
        public void Validate_NullCode_ReturnFalse()
        {
            //arrange
            var zipcode = new Zipcode()
            {
                Code = null,
            };
            var zipcodeValidator = new ZipcodeValidator();

            //act
            var validationResponse = zipcodeValidator.Validate(zipcode);

            //assert
            Assert.IsFalse(validationResponse.IsValid);
            Assert.IsNotNull(validationResponse.Message);
        }
Exemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CardNumber.Length != 0)
            {
                hash ^= CardNumber.GetHashCode();
            }
            if (Cvc.Length != 0)
            {
                hash ^= Cvc.GetHashCode();
            }
            if (ExpiryMonth != 0)
            {
                hash ^= ExpiryMonth.GetHashCode();
            }
            if (FourDigitExpiryYear != 0)
            {
                hash ^= FourDigitExpiryYear.GetHashCode();
            }
            if (Zipcode.Length != 0)
            {
                hash ^= Zipcode.GetHashCode();
            }
            if (CardholderName.Length != 0)
            {
                hash ^= CardholderName.GetHashCode();
            }
            if (IsVirtualCard != false)
            {
                hash ^= IsVirtualCard.GetHashCode();
            }
            if (virtualCardLimit_ != null)
            {
                hash ^= VirtualCardLimit.GetHashCode();
            }
            if (virtualCardAvailableOn_ != null)
            {
                hash ^= VirtualCardAvailableOn.GetHashCode();
            }
            if (virtualCardExpiresOn_ != null)
            {
                hash ^= VirtualCardExpiresOn.GetHashCode();
            }
            return(hash);
        }
        public void Remove(Zipcode zipcode)
        {
            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("DELETE FROM [dbo].[zipcode]");
                sb.Append("WHERE [ZipCodeID] = " + zipcode.ZipCodeID);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
        public async Task GetWeatherInfoForZipcodeAsync_ReturnsWeather()
        {
            //arrange
            var mockHttpClientFactory = new Mock <IHttpClientFactory>();

            mockHttpClientFactory.Setup(f => f.CreateClient("openweather")).Returns(_weatherHttpClient);
            var client  = new OpenWeatherApiClient(mockHttpClientFactory.Object);
            var zipcode = new Zipcode("97219");

            //act
            ApiResponse <WeatherInfo> apiResponse = await client.GetWeatherInfoForZipcodeAsync(zipcode);

            //assert
            Assert.IsNotNull(apiResponse.Data);
            Assert.IsTrue(apiResponse.IsSuccess);
            StringAssert.AreEqualIgnoringCase("Portland", apiResponse.Data.City);
            Assert.IsNotNull(apiResponse.Data.TempKelvin);
        }
Exemplo n.º 7
0
        public static Zipcode GetCSZ(int z)
        {
            Database  db = DatabaseFactory.CreateDatabase();
            DbCommand cw = db.GetStoredProcCommand("sp_NCIPL_GetCSZ");

            db.AddInParameter(cw, "zip", DbType.String, z.ToString());
            using (System.Data.IDataReader dr = db.ExecuteReader(cw))
            {
                Zipcode k = new Zipcode();
                if (dr.Read())
                {
                    //k.zip5=z;
                    k.City  = dr["City"].ToString();
                    k.State = dr["State"].ToString();
                    k.Zip4  = dr["zip4"].ToString();
                }
                return(k);  //May or may not have real values at this point...thats ok.
            }
        }
Exemplo n.º 8
0
        private void BindBillingInfo(Person p)
        {
            txt2name.Text  = p.Fullname;
            txt2org.Text   = p.Organization;
            txt2addr1.Text = p.Addr1;
            txt2addr2.Text = p.Addr2;
            txt2phone.Text = p.Phone;
            txt2email.Text = p.Email;

            txt2zip5.Text  = p.Zip5;
            txt2zip4.Text  = p.Zip4;
            txt2city.Text  = p.City;
            txt2state.Text = p.State;
            foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(p.Zip5)))
            {
                drpcity2.Items.Add(new ListItem(city.Key, city.Key));
            }
            drpcity2.SelectedValue = p.City;
        }
Exemplo n.º 9
0
        protected override async Task Handle(SaveZipcodeCommand command)
        {
            var city = _cityRepository.GetByAltId(command.CityAltId);

            if (city != null)
            {
                var zipcode = new Zipcode
                {
                    AltId      = Guid.NewGuid(),
                    Postalcode = command.Zipcode,
                    Region     = command.Region,
                    CityId     = city.Id,
                    ModifiedBy = command.ModifiedBy,
                    CreatedUtc = DateTime.UtcNow,
                    IsEnabled  = true
                };

                _zipcodeRepository.Save(zipcode);
            }
        }
Exemplo n.º 10
0
        private void BindShippingInfo(Person p)
        {
            txtname.Text  = p.Fullname;
            txtorg.Text   = p.Organization;
            txtaddr1.Text = p.Addr1;
            txtaddr2.Text = p.Addr2;
            txtphone.Text = p.Phone;
            txtemail.Text = p.Email;

            txtzip5.Text  = p.Zip5;
            txtzip4.Text  = p.Zip4;
            txtcity.Text  = p.City;
            txtstate.Text = p.State;
            foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(p.Zip5)))
            {
                drpcity2.Items.Add(new ListItem(city.Key, city.Key));
            }
            drpcity2.SelectedValue = billto.City;
            //txtcity.Visible = true;
            //drpcity.Visible = false;
        }
Exemplo n.º 11
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            // Validation 1 : Zip code has to be between
            if (Address2 == Address1)
            {
                yield return(new ValidationResult("Address2 cannot be same as Address 1"));
            }
            if (State != null && State.Split(' ').Length > 2)
            {
                yield return(new ValidationResult("Enter 2 digit State code "));
            }
            if (Zipcode != null && Zipcode.Split(' ').Length < 5)
            {
            }
            else
            {
                yield return(new ValidationResult("Enter a 5 digit Zipcode"));
            }

            //throw new NotImplementedException();
        }
        public async Task <IActionResult> Get([FromQuery] Zipcode zipcode)
        {
            var apiResponse = new ApiResponse <CayuseZipcodeInfo>();

            try
            {
                apiResponse = await _zipcodeInfoProcessor.GenerateZipcodeInfoAsync(zipcode);

                if (apiResponse.IsValidationError)
                {
                    return(BadRequest(apiResponse));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500));
                //todo log exception
            }

            return(new JsonResult(apiResponse));
        }
Exemplo n.º 13
0
        public void BarDelete()
        {
            //Setup
            ManagerController mc      = new ManagerController();
            Manager           manager = new Manager("TestName", "TestPhonenumber", "TestEmail", "TestUsername", null);
            Manager           m       = mc.CreateManager(manager, "TestPassword");

            Country country = LocationDB.Instance.getCountryById(1);

            if (country is null)
            {
                Assert.Fail("Country is null");
            }
            Zipcode zip = LocationDB.Instance.findZipById(1);
            Address a   = new Address("TestVej", zip);

            zip.Country = country;
            a.Zipcode   = zip;

            Bar bar = new Bar
            {
                Address     = a,
                Email       = "TestBarEmail",
                Name        = "TestBarName",
                PhoneNumber = "TestBarP",
                Username    = "******"
            };

            Bar expected = controller.Create(bar, m.Id, "TestPassword");
            //Act
            bool isSuccess = controller.Delete(expected.ID);

            //Assert 1
            Bar notFound = controller.Find(expected.ID);

            Assert.IsNull(notFound);

            //Assert 2
            Assert.AreEqual(isSuccess, true, "The method returns an unexpected value");
        }
Exemplo n.º 14
0
        static void CreateZipcode()
        {
            Console.Write("Please enter a new zipcode: ");
            int.TryParse(Console.ReadLine(), out int zipcode);
            Console.Write("Please enter a city: ");
            string city = Console.ReadLine();

            Console.Write("Please enter a state (MI): ");
            string state = Console.ReadLine();

            using (var ctx = new Context())
            {
                var zip = new Zipcode
                {
                    Zip   = zipcode,
                    City  = city,
                    State = state
                };
                ctx.Zipcodes.Add(zip);
                ctx.SaveChanges();
            }
        }
Exemplo n.º 15
0
        protected override async Task Handle(SaveAddressCommand command)
        {
            var user    = _userRepository.GetByAltId(command.UserAltId);
            var zipcode = _zipcodeRepository.GetByZipcode(command.Zipcode.ToString());

            if (zipcode == null)
            {
                var zipCode = new Zipcode
                {
                    AltId      = Guid.NewGuid(),
                    Postalcode = command.Zipcode.ToString(),
                    IsEnabled  = true
                };

                _zipcodeRepository.Save(zipCode);

                zipcode = _zipcodeRepository.GetByZipcode(command.Zipcode.ToString());
            }
            if (user != null && zipcode != null)
            {
                var addressDetail = new UserAddressDetail
                {
                    UserId        = user.Id,
                    AltId         = Guid.NewGuid(),
                    FirstName     = command.FirstName,
                    LastName      = command.LastName,
                    PhoneCode     = command.PhoneCode,
                    PhoneNumber   = command.PhoneNumber,
                    AddressLine1  = command.AddressLine1,
                    Zipcode       = zipcode.Id,
                    AddressTypeId = command.AddressTypeId,
                    ModifiedBy    = command.ModifiedBy,
                    IsEnabled     = true,
                    CityId        = null
                };

                _userAddressDetailRepository.Save(addressDetail);
            }
        }
        public void Update(Zipcode zipcode)
        {
            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("UPDATE [dbo].[zipcode]");
                sb.Append("SET [ZipCode] = @param1, [City] = @param2, [State] = @param3, [Business] = @param4");
                sb.Append(" WHERE [ZipCodeID] = " + zipcode.ZipCodeID);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.Parameters.Add("@param1", SqlDbType.NVarChar, 11).Value           = (object)zipcode.ZipCode ?? DBNull.Value;
                    command.Parameters.Add("@param2", SqlDbType.NVarChar, 50).Value           = (object)zipcode.City ?? DBNull.Value;
                    command.Parameters.Add("@param3", SqlDbType.NVarChar, int.MaxValue).Value = (object)zipcode.State ?? DBNull.Value;
                    command.Parameters.Add("@param4", SqlDbType.NVarChar, int.MaxValue).Value = (object)zipcode.Business ?? DBNull.Value;
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
        public void Insert(Zipcode zipcode)
        {
            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [dbo].[zipcode]([ZipCode],[City],[State],[Business])");
                string values = "VALUES(@param1, @param2, @param3, @param4)";
                sb.Append(values);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.Parameters.Add("@param1", SqlDbType.NVarChar, 11).Value           = (object)zipcode.ZipCode ?? DBNull.Value;
                    command.Parameters.Add("@param2", SqlDbType.NVarChar, 50).Value           = (object)zipcode.City ?? DBNull.Value;
                    command.Parameters.Add("@param3", SqlDbType.NVarChar, int.MaxValue).Value = (object)zipcode.State ?? DBNull.Value;
                    command.Parameters.Add("@param4", SqlDbType.NVarChar, int.MaxValue).Value = (object)zipcode.Business ?? DBNull.Value;
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 18
0
        public void BarrUpdateName()
        {
            //Setup
            //setup
            ManagerController mc      = new ManagerController();
            Manager           manager = new Manager("TestName", "TestPhonenumber", "TestEmail", "TestUsername", null);
            Manager           m       = mc.CreateManager(manager, "TestPassword");

            Country country = LocationDB.Instance.getCountryById(1);

            if (country is null)
            {
                Assert.Fail("Country is null");
            }
            Zipcode zip = LocationDB.Instance.findZipById(1);
            Address a   = new Address("TestVej", zip);

            zip.Country = country;
            a.Zipcode   = zip;

            Bar bar = new Bar
            {
                Address     = a,
                Email       = "TestBarEmail",
                Name        = "TestBarName",
                PhoneNumber = "TestBarP",
                Username    = "******"
            };
            Bar expected = controller.Create(bar, m.Id, "TestPassword");

            expected.Name = "TestNameUpdated";
            //Act
            controller.Update(expected.ID, expected.Name, a, expected.PhoneNumber, expected.Email, expected.Username);
            Bar actual = controller.Find(expected.ID);

            //Assert
            Assert.AreEqual(expected, actual, "Bar name was not updated correctly");
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns true if Forecast instances are equal
        /// </summary>
        /// <param name="other">Instance of Forecast to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Forecast other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Zipcode == other.Zipcode ||
                     Zipcode != null &&
                     Zipcode.Equals(other.Zipcode)
                     ) &&
                 (
                     Day == other.Day ||
                     Day != null &&
                     Day.Equals(other.Day)
                 ) &&
                 (
                     High == other.High ||
                     High != null &&
                     High.Equals(other.High)
                 ) &&
                 (
                     Low == other.Low ||
                     Low != null &&
                     Low.Equals(other.Low)
                 ) &&
                 (
                     Detail == other.Detail ||
                     Detail != null &&
                     Detail.Equals(other.Detail)
                 ));
        }
Exemplo n.º 20
0
        //***EAC update count, shipcosts etc
        protected void BindTotals(string state)
        {
            if (Zipcode.isXPO(state))
            {
                HideBillingItems();
            }
            else
            {
                ShowBillingItems();
            }

            //Display the master page tabs
            GlobalUtils.Utils UtilMethod = new GlobalUtils.Utils();
            if (Session["NCIPL_Pubs"] != null)
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp(Session["NCIPL_Qtys"].ToString(), "");
            }
            else
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp("", "");
            }
            UtilMethod = null;
        }
Exemplo n.º 21
0
        protected void Zip_Changed(object sender, EventArgs e)
        {
            if (txtzip5.Text.Length == 5)
            {
                //***EAC HITT 7460
                drpcity.Items.Clear();
                txtstate.Text = "";
                try
                {
                    foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(txtzip5.Text)))
                    {
                        drpcity.Items.Add(new ListItem(city.Key, city.Key));
                        txtstate.Text = city.Val; //doesn't hurt to do this n times
                    }
                    txtcity.Visible = true;       //**just in case the line below throws an error
                    drpcity.Visible = false;      //**just in case the line below throws an error
                    txtcity.Text    = drpcity.Items[0].Text;
                    if (drpcity.Items.Count <= 1)
                    {
                        txtcity.Visible = true;
                        drpcity.Visible = false;
                        lbltxtcity.AssociatedControlID = "txtcity";
                    }
                    else
                    {
                        txtcity.Visible = false;
                        drpcity.Visible = true;
                        lbltxtcity.AssociatedControlID = "drpcity";
                    }

                    BindTotals(txtstate.Text);
                }
                catch (Exception ex) {
                    Console.Write(ex.Message);
                }
            }
        }
Exemplo n.º 22
0
        protected void BillZip_Changed(object sender, EventArgs e)
        {
            if (txt2zip5.Text.Length == 5)
            {
                //***EAC HITT 7460
                drpcity2.Items.Clear();
                txt2state.Text = "";
                try
                {
                    foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(txt2zip5.Text)))
                    {
                        drpcity2.Items.Add(new ListItem(city.Key, city.Key));
                        txt2state.Text = city.Val; //doesn't hurt to do this n times
                    }
                    txt2city.Visible = true;       //**just in case the line below throws an error
                    drpcity2.Visible = false;      //**just in case the line below throws an error
                    txt2city.Text    = drpcity2.Items[0].Text;
                    if (drpcity2.Items.Count <= 1)
                    {
                        txt2city.Visible = true;
                        drpcity2.Visible = false;
                        lbltxt2city.AssociatedControlID = "txt2city";
                    }
                    else
                    {
                        txt2city.Visible = false;
                        drpcity2.Visible = true;
                        lbltxt2city.AssociatedControlID = "drpcity2";
                    }
                }
                catch { }
            }

            //Zipcode z = Zipcode.GetCSZ(Int32.Parse(txt2zip5.Text));
            //txt2city.Text = z.City;
            //txt2state.Text = z.State;
        }
Exemplo n.º 23
0
    //***************************** insertZipIfNotExist **************************************//
    private void insertZipIfNotExist()
    {
        try
        {
            Zipcode zp = new Zipcode();
            Zipcode result = lookupZipcode();

            //the zipcode doesn't exist already. Add it to the database.
            if (result == null)
            {
                using (CCSEntities db = new CCSEntities())
                {
                    zp.ZipCode1 = txtZip.Text.ToString();
                    db.Zipcodes.Add(zp);
                    db.SaveChanges();

                } //end of db connection
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            LogError.logError(ex);
            Response.Redirect("../errorpages/error.aspx");
        }
    }
Exemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Utils.ValidateRedirect().Length > 0) //Important check
            {
                Response.Redirect(Utils.ValidateRedirect(), true);
            }

            if (this.shoppingcart == null || this.shoppingcart.Count < 1)
            {  //***EAC I need a shopping cart at this point
                ResetSessions();
                Response.Redirect("home.aspx?missingcart=true", true);
            }

            IsOrderIntl = Utils.IsOrderInternational(); //NCIPLex - International or domestic

            if (!IsPostBack)
            {
                steps1.Activate("cell3");

                this.shoppingcartV2 = VirtualizedCart(this.shoppingcart);
                if (this.cc == null)
                {
                    this.cc = new CreditCard();
                }
                this.cc.Cost = this.shoppingcartV2.Cost;      //assume cart exists...if not error handler will take care of it

                for (int i = DateTime.Now.Year; i < DateTime.Now.Year + 9; i++)
                {
                    drpyr.Items.Add(new ListItem(i.ToString(), i.ToString().Substring(2)));
                }

                ddlIntlCountry.DataSource    = NCIPLex.DAL.SQLDataAccess.GetKVPairStr("SP_NCIPLex_GetCountry");
                ddlIntlCountry.DataTextField = "Val";
                //ddlIntlCountry.DataValueField = "Key";
                ddlIntlCountry.DataValueField = "Val";
                ddlIntlCountry.DataBind();
                ddlIntlCountry.Items.Insert(0, new ListItem("[Select from the list]", ""));

                if (this.shipto != null)
                {
                    #region Restore ship vals
                    try
                    {
                        txtzip5.Text  = shipto.Zip5;
                        txtzip4.Text  = shipto.Zip4;
                        txtcity.Text  = shipto.City;
                        txtstate.Text = shipto.State;
                        //foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(shipto.Zip5)))
                        //    drpcity.Items.Add(new ListItem(city.Key, city.Key));
                        //drpcity.SelectedValue = shipto.City;
                        txtcity.Text    = shipto.City;
                        txtcity.Visible = true;
                        drpcity.Visible = false;
                        txtname.Text    = shipto.Fullname;
                        txtorg.Text     = shipto.Organization;
                        txtaddr1.Text   = shipto.Addr1;
                        txtaddr2.Text   = shipto.Addr2;
                        txtphone.Text   = shipto.Phone;
                        txtemail.Text   = shipto.Email;

                        if (IsOrderIntl)
                        {
                            txtIntlZip.Text   = shipto.Zip5;
                            txtIntlState.Text = shipto.State;
                            //txtIntlCountry.Text = shipto.Country;
                            ddlIntlCountry.SelectedValue = shipto.Country;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    #endregion
                }

                if (this.billto != null)
                {
                    #region Restore bill vals
                    try
                    {
                        txt2zip5.Text  = billto.Zip5;
                        txt2zip4.Text  = billto.Zip4;
                        txt2city.Text  = billto.City;
                        txt2state.Text = billto.State;
                        foreach (KVPair city in Zipcode.GetCities(Convert.ToInt32(billto.Zip5)))
                        {
                            drpcity2.Items.Add(new ListItem(city.Key, city.Key));
                        }
                        drpcity2.SelectedValue = billto.City;
                        txt2name.Text          = billto.Fullname;
                        txt2org.Text           = billto.Organization;
                        txt2addr1.Text         = billto.Addr1;
                        txt2addr2.Text         = billto.Addr2;
                        txt2phone.Text         = billto.Phone;
                        txt2email.Text         = billto.Email;
                    }
                    catch (Exception)
                    {
                    }
                    #endregion
                }

                //JPJ 03-10-11 NCIPLex does not accept credit card orders
                //if (this.cc != null && this.cc.Cost > 0.0)
                //{
                //    Label1.Text = "Shipping & Payment";
                //    pnlPaymentInfo.Visible = true;
                //    #region Restor CC field values
                //    drpcard.SelectedValue = cc.Company;
                //    txtccnum.Text = cc.CCnum;
                //    txtcvv2.Text = cc.CVV2;
                //    drpmonth.SelectedValue = cc.ExpMon;
                //    drpyr.SelectedValue = cc.ExpYr;
                //    lblCost.Text = this.cc.Cost.ToString("c");
                //    #endregion
                //}
                //else
                //{
                Label1.Text            = "Shipping";
                pnlPaymentInfo.Visible = false;
                pnlBIllingInfo.Visible = false;
                chkSameaddress.Visible = false;
                lblBill.Visible        = false;
                lblShip.Visible        = false;
                rowIntlCountry.Visible = false;
                //}

                if (IsOrderIntl)
                {
                    lbltxtzip5.Visible  = false;
                    txtzip5.Visible     = false;
                    lbltxtzip4.Visible  = false;
                    txtzip4.Visible     = false;
                    lbltxtstate.Visible = false;
                    txtstate.Visible    = false;

                    txtphone.ToolTip = "";

                    RegularExpressionValidator3.Visible = false;
                    RegularExpressionValidator6.Visible = false;
                    RequiredFieldValidator13.Visible    = false;
                    RegularExpressionValidator5.Visible = false;
                    RequiredFieldValidator6.Visible     = false;


                    lblIntltxtzip.Visible     = true;
                    txtIntlZip.Visible        = true;
                    lbltxtIntlState.Visible   = true;
                    txtIntlState.Visible      = true;
                    rowIntlCountry.Visible    = true;
                    divlblCountry.Visible     = true;
                    lbltxtIntlCountry.Visible = true;
                    divtxtCountry.Visible     = true;
                    //txtIntlCountry.Visible = true;
                    ddlIntlCountry.Visible           = true;
                    RequiredFieldIntlZip.Visible     = true;
                    RequiredFieldIntlCountry.Visible = true;
                }
            }

            //Display the master page tabs
            GlobalUtils.Utils UtilMethod = new GlobalUtils.Utils();
            if (Session["NCIPLEX_Pubs"] != null)
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp(Session["NCIPLEX_Qtys"].ToString(), "");
            }
            else
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp("", "");
            }
            UtilMethod = null;
        }
Exemplo n.º 25
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            #region Toggle Billing Validators
            if (chkSameaddress.Checked)
            {
                RequiredFieldValidator9.Enabled  = false;
                RequiredFieldValidator10.Enabled = false;
                RequiredFieldValidator11.Enabled = false;
                RequiredFieldValidator12.Enabled = false;
                RequiredFieldValidator14.Enabled = false;
                RequiredFieldValidator16.Enabled = false;
                RequiredFieldValidator17.Enabled = false;

                RegularExpressionValidator2.Enabled = false;
                RegularExpressionValidator4.Enabled = false;
            }
            else
            {
                RequiredFieldValidator9.Enabled  = true;
                RequiredFieldValidator10.Enabled = true;
                RequiredFieldValidator11.Enabled = true;
                RequiredFieldValidator12.Enabled = true;
                RequiredFieldValidator14.Enabled = true;
                RequiredFieldValidator16.Enabled = true;
                RequiredFieldValidator17.Enabled = true;

                RegularExpressionValidator2.Enabled = true;
                RegularExpressionValidator4.Enabled = true;
            }
            #endregion

            if (Page.IsValid)
            {
                //*** EAC We passed .Net validation so now just
                //*** validate the lengths so AppScan doesn't get angry
                if (txtzip5.Text.Length + txtzip4.Text.Length + txtcity.Text.Length + txtstate.Text.Length +
                    txtname.Text.Length + txtorg.Text.Length + txtaddr1.Text.Length + txtaddr2.Text.Length + txtphone.Text.Length + txtemail.Text.Length > 220)
                {
                    throw (new ArgumentOutOfRangeException("Shipping object is too big"));
                }

                if (txt2zip5.Text.Length + txt2zip4.Text.Length + txt2city.Text.Length + txt2state.Text.Length +
                    txt2name.Text.Length + txt2org.Text.Length + txt2addr1.Text.Length + txt2addr2.Text.Length + txt2phone.Text.Length + txt2email.Text.Length > 220)
                {
                    throw (new ArgumentOutOfRangeException("Billing object is too big"));
                }

                //***EAC At this point, data looks clean
                this.shipto = new Person(1, txtname.Text, txtorg.Text, txtemail.Text, txtaddr1.Text, txtaddr2.Text, (txtcity.Visible == true ? txtcity.Text : drpcity.SelectedValue), txtstate.Text, txtzip5.Text, txtzip4.Text, txtphone.Text);
                //this.cc = new CreditCard(drpcard.SelectedValue, txtccnum.Text, drpmonth.SelectedValue, drpyr.SelectedValue, txtcvv2.Text, this.cc.Cost, drpcard.SelectedValue );
                if (chkSameaddress.Checked)
                {
                    this.billto = this.shipto;
                }
                else
                {
                    this.billto = new Person(1, txt2name.Text, txt2org.Text, txt2email.Text, txt2addr1.Text, txt2addr2.Text, (txt2city.Visible == true ? txt2city.Text : drpcity2.SelectedValue), txt2state.Text, txt2zip5.Text, txt2zip4.Text, txt2phone.Text);
                }

                if (!UserExists(txtUserName.Text.ToString()))
                {
                    //*** Update PubEnt Registration table
                    bool retSaveRegistration = DAL.DAL.SaveRegistration(txtUserName.Text, shipto, billto, -1);  //***EAC typeofcustomerid is now ignored

                    if (retSaveRegistration)
                    {
                        //*** Create user in GUAM
                        try
                        {
                            new UserServiceClient().Using(client =>
                            {
                                ReturnObject ro;

                                //*** Add a new user
                                ro = client.AddUser(txtUserName.Text.ToString());
                                if (ro.ReturnCode != 0)
                                {
                                    RemoveUser();
                                    lblGuamMsg.Text    = ro.DefaultErrorMessage;
                                    lblGuamMsg.Visible = true;
                                }
                                else
                                {
                                    lblGuamMsg.Text    = "";
                                    lblGuamMsg.Visible = false;
                                    //*** Set User Email
                                    ro = client.SetUserMetaData(txtUserName.Text.ToString(), "Email", txtUserName.Text.ToString());

                                    //*** Generate Password
                                    ro            = client.GeneratePassword(txtUserName.Text.ToString());
                                    string newpwd = ro.ReturnValue.ToString();

                                    //*** Assign Password
                                    ro = client.AssignPassword(txtUserName.Text.ToString(), newpwd);

                                    //*** Set questions and answer
                                    UserQuestion[] questions_answer  = new UserQuestion[1];
                                    questions_answer[0]              = new UserQuestion();
                                    questions_answer[0].QuestionText = ddlQuestions.SelectedItem.Text;
                                    questions_answer[0].Answer       = txtAnswer.Text;
                                    ro = client.SetUserQuestionsAndAnswers(txtUserName.Text.ToString(), questions_answer);

                                    //*** Add User to Role
                                    ro = client.AddUserToRole(txtUserName.Text.ToString(), "NCIPL_PUBLIC");

                                    //*** Registration Complete
                                    divUserReg.Visible             = false;
                                    divUserRegConfirmation.Visible = true;
                                    lblRegUserName.Text            = txtUserName.Text;
                                    lblRegPassword.Text            = newpwd;

                                    if (Zipcode.isXPO(txtstate.Text))
                                    {
                                        lblXPO.Text = "Please note: We will provide free shipping via U.S. Postal Service for orders up to " + PubEnt.GlobalUtils.Const.XPOMaxQuantity.ToString() + " items to your location. We are sorry we cannot send orders of more than " + PubEnt.GlobalUtils.Const.XPOMaxQuantity.ToString() + " items or send items via FedEx or UPS to your shipping address.";
                                    }
                                    Session["NCIPL_User"] = txtUserName.Text;
                                }
                            });
                        }
                        catch
                        {
                            RemoveUser();
                            divUserRegConfirmation.Visible = false;
                            lblGuamMsg.Text    = GuamErrorMsg;
                            lblGuamMsg.Visible = true;
                        }
                    }
                    else
                    {
                        divUserRegConfirmation.Visible = false;
                        lblGuamMsg.Text    = PubEntErrorMsg;
                        lblGuamMsg.Visible = true;
                    }
                }
                else
                {
                    divUserRegConfirmation.Visible = false;
                    lblGuamMsg.Text    = "You already have an account with us. Please login with your username and password or select the option to reset your password.";
                    lblGuamMsg.Visible = true;
                }
            }
        }
Exemplo n.º 26
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            #region Toggle Billing Validators
            if (chkSameaddress.Checked)
            {
                RequiredFieldValidator9.Enabled  = false;
                RequiredFieldValidator10.Enabled = false;
                RequiredFieldValidator11.Enabled = false;
                RequiredFieldValidator12.Enabled = false;
                RequiredFieldValidator14.Enabled = false;
                RequiredFieldValidator16.Enabled = false;
                RequiredFieldValidator17.Enabled = false;

                RegularExpressionValidator2.Enabled = false;
                RegularExpressionValidator4.Enabled = false;
            }
            else
            {
                RequiredFieldValidator9.Enabled  = true;
                RequiredFieldValidator10.Enabled = true;
                RequiredFieldValidator11.Enabled = true;
                RequiredFieldValidator12.Enabled = true;
                RequiredFieldValidator14.Enabled = true;
                RequiredFieldValidator16.Enabled = true;
                RequiredFieldValidator17.Enabled = true;

                RegularExpressionValidator2.Enabled = true;
                RegularExpressionValidator4.Enabled = true;
            }
            #endregion

            if (Page.IsValid)
            {
                //*** EAC We passed .Net validation so now just
                //*** validate the lengths so AppScan doesn't get angry
                if (txtzip5.Text.Length + txtzip4.Text.Length + txtcity.Text.Length + txtstate.Text.Length +
                    txtname.Text.Length + txtorg.Text.Length + txtaddr1.Text.Length + txtaddr2.Text.Length + txtphone.Text.Length + txtemail.Text.Length > 220)
                {
                    throw (new ArgumentOutOfRangeException("Shipping object is too big"));
                }

                if (txt2zip5.Text.Length + txt2zip4.Text.Length + txt2city.Text.Length + txt2state.Text.Length +
                    txt2name.Text.Length + txt2org.Text.Length + txt2addr1.Text.Length + txt2addr2.Text.Length + txt2phone.Text.Length + txt2email.Text.Length > 220)
                {
                    throw (new ArgumentOutOfRangeException("Billing object is too big"));
                }

                //***EAC At this point, data looks clean
                this.shipto = new Person(1, txtname.Text, txtorg.Text, txtemail.Text, txtaddr1.Text, txtaddr2.Text, (txtcity.Visible == true ? txtcity.Text : drpcity.SelectedValue), txtstate.Text, txtzip5.Text, txtzip4.Text, txtphone.Text);
                //this.cc = new CreditCard(drpcard.SelectedValue, txtccnum.Text, drpmonth.SelectedValue, drpyr.SelectedValue, txtcvv2.Text, this.cc.Cost, drpcard.SelectedValue );
                if (chkSameaddress.Checked)
                {
                    this.billto = this.shipto;
                }
                else
                {
                    this.billto = new Person(1, txt2name.Text, txt2org.Text, txt2email.Text, txt2addr1.Text, txt2addr2.Text, (txt2city.Visible == true ? txt2city.Text : drpcity2.SelectedValue), txt2state.Text, txt2zip5.Text, txt2zip4.Text, txt2phone.Text);
                }

                //*** Update PubEnt Registration table
                bool retSaveRegistration = DAL.DAL.UpdateRegistration(Session["NCIPL_User"].ToString(), shipto, billto);

                if (retSaveRegistration)
                {
                    //*** Update Registration Complete
                    divUserReg.Visible             = false;
                    divUserRegConfirmation.Visible = true;
                    if (Zipcode.isXPO(txtstate.Text))
                    {
                        lblXPO.Text = "Please note: We will provide free shipping via U.S. Postal Service for orders up to " + PubEnt.GlobalUtils.Const.XPOMaxQuantity.ToString() + " items to your location. We are sorry we cannot send orders of more than " + PubEnt.GlobalUtils.Const.XPOMaxQuantity.ToString() + " items or send items via FedEx or UPS to your shipping address.";
                    }
                }
                else
                {
                    divUserRegConfirmation.Visible = false;
                    lblGuamMsg.Text    = PubEntErrorMsg;
                    lblGuamMsg.Visible = true;
                }
            }
        }
Exemplo n.º 27
0
        public SavedEventQueryResult Handle(SavedEventQuery query)
        {
            var eventDataModel = _eventRepository.GetByAltId(query.Id);
            var eventModel     = AutoMapper.Mapper.Map <Contracts.Models.Event>(eventDataModel);

            var placeVisitDuration = _placeVisitDurationRepository.GetBySingleEventId(eventModel.Id);

            var galleryImageResponse = _eventGalleryImageRepository.GetByEventId(eventModel.Id);
            var galleryImageModel    = AutoMapper.Mapper.Map <IEnumerable <EventGalleryImage> >(galleryImageResponse);

            var eventcatmapresponse = _eventCategoryMappingRepository.GetByEventId(eventModel.Id);
            var eventcatmap         = AutoMapper.Mapper.Map <IEnumerable <EventCategoryMapping> >(eventcatmapresponse);

            var eventsiteidresponse = _eventSiteIdMappingRepository.GetByEventId(eventModel.Id);
            var eventsitemap        = AutoMapper.Mapper.Map <EventSiteIdMapping>(eventsiteidresponse);

            var eventlearnmoreresponse = _eventLearnMoreAttributeRepository.GetByEventId(eventModel.Id);
            var eventlearnmore         = AutoMapper.Mapper.Map <IEnumerable <EventLearnMoreAttribute> >(eventlearnmoreresponse);

            var eventamenityresponse = _eventAmenityRepository.GetByEventId(eventModel.Id);
            var eventamenity         = AutoMapper.Mapper.Map <IEnumerable <EventAmenity> >(eventamenityresponse);

            var eventdetailresponse = _eventDetailRepository.GetSubeventByEventId(eventModel.Id).FirstOrDefault();
            var eventdetail         = AutoMapper.Mapper.Map <EventDetail>(eventdetailresponse);

            var eventTags = _eventTagMappingRepository.GetByEventId(eventModel.Id);

            Country countrydetail = new Country();
            City    citydetail    = new City();
            State   statedetail   = new State();
            Zipcode zipcodeDetail = new Zipcode();
            Venue   venuedetail   = new Venue();

            if (eventdetail != null)
            {
                var venuedetailresponse = _venueRepository.GetByVenueId(eventdetail.VenueId);
                venuedetail = AutoMapper.Mapper.Map <Venue>(venuedetailresponse);
                if (venuedetail != null)
                {
                    var citydetailresponse = _cityRepository.GetByCityId(venuedetail.CityId);
                    citydetail = AutoMapper.Mapper.Map <City>(citydetailresponse);
                    var Zip = _zipcodeRepository.GetAllByCityId(citydetail.Id).FirstOrDefault();
                    zipcodeDetail = AutoMapper.Mapper.Map <Zipcode>(Zip);
                }
                if (citydetail != null)
                {
                    var statedetailresponse = _stateRepository.GetByStateId(citydetail.StateId);
                    statedetail = AutoMapper.Mapper.Map <State>(statedetailresponse);
                }
                if (statedetail != null)
                {
                    var countrydetailresponse = _countryRepository.GetByCountryId(statedetail.CountryId);
                    countrydetail = AutoMapper.Mapper.Map <Country>(countrydetailresponse);
                }
            }

            var features   = Enum.GetValues(typeof(LearnMoreFeatures));
            var resultdata = new SavedEventQueryResult();

            resultdata.Country  = countrydetail.Name;
            resultdata.City     = citydetail.Name;
            resultdata.Address1 = venuedetail.AddressLineOne;
            resultdata.Address2 = venuedetail.AddressLineTwo;
            resultdata.State    = statedetail.Name;
            resultdata.Lat      = ((venuedetail.Latitude != null && venuedetail.Latitude != "" && venuedetail.Latitude != "NaN") ? venuedetail.Latitude : "18.5204");
            resultdata.Long     = ((venuedetail.Longitude != null && venuedetail.Longitude != "" && venuedetail.Latitude != "NaN") ? venuedetail.Longitude : "73.8567");
            List <string> amenityids = new List <string>();

            if (zipcodeDetail != null)
            {
                if (zipcodeDetail.Id != 0)
                {
                    resultdata.Zip = zipcodeDetail.Postalcode;
                }
            }
            foreach (var ea in eventamenity)
            {
                amenityids.Add((ea.AmenityId).ToString());
            }
            if (placeVisitDuration != null)
            {
                var data = placeVisitDuration.TimeDuration.Split("-");
                if (data.Length >= 2)
                {
                    resultdata.HourTimeDuration   = placeVisitDuration.TimeDuration;
                    resultdata.MinuteTimeDuration = "";
                }
            }
            resultdata.AmenityId = string.Join(",", amenityids);
            //resultdata.AmenityId = string.Join(",", amenityids);
            var archdesc = eventlearnmore.FirstOrDefault(p => p.LearnMoreFeatureId == LearnMoreFeatures.ArchitecturalDetail);

            if (archdesc != null)
            {
                resultdata.Archdetail   = archdesc.Description;
                resultdata.ArchdetailId = archdesc.Id;
            }
            var highlightdesc = eventlearnmore.FirstOrDefault(p => p.LearnMoreFeatureId == LearnMoreFeatures.HighlightNugget);

            if (highlightdesc != null)
            {
                resultdata.Highlights   = highlightdesc.Description;
                resultdata.HighlightsId = highlightdesc.Id;
            }
            var historydesc = eventlearnmore.FirstOrDefault(p => p.LearnMoreFeatureId == LearnMoreFeatures.History);

            if (historydesc != null)
            {
                resultdata.History   = historydesc.Description;
                resultdata.HistoryId = historydesc.Id;
            }
            var immersdesc = eventlearnmore.FirstOrDefault(p => p.LearnMoreFeatureId == LearnMoreFeatures.ImmersiveExperience);

            if (immersdesc != null)
            {
                resultdata.Immersiveexperience   = immersdesc.Description;
                resultdata.ImmersiveexperienceId = immersdesc.Id;
            }

            var tilesImages         = "";
            var galleryImages       = galleryImageModel.Where(p => p.Name.Contains("gallery"));
            var tilesSliderImages   = galleryImageModel.Where(p => p.Name.Contains("Tiles"));
            var descPageImages      = galleryImageModel.Where(p => p.Name.Contains("DescBanner"));
            var inventoryPageImages = galleryImageModel.Where(p => p.Name.Contains("InventoryBanner"));
            var placeMapImages      = galleryImageModel.Where(p => p.Name.Contains("placemapImages"));
            var timelineImages      = galleryImageModel.Where(p => p.Name.Contains("timelineImages"));
            var immersiveImages     = galleryImageModel.Where(p => p.Name.Contains("immersiveImages"));
            var architecturalImages = galleryImageModel.Where(p => p.Name.Contains("archdetailImages"));

            var galleryImagesList     = "";
            var tilesSliderImagesList = "";
            var descPageList          = "";
            var inventoryPageList     = "";
            var plaeMapImagesList     = "";
            var timelineImagesList    = "";
            var immerseImagesList     = "";
            var archImagesList        = "";

            foreach (EventGalleryImage eventGalleryImage in galleryImages)
            {
                galleryImagesList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in tilesSliderImages)
            {
                tilesSliderImagesList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in descPageImages)
            {
                descPageList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in inventoryPageImages)
            {
                inventoryPageList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in placeMapImages)
            {
                plaeMapImagesList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in timelineImages)
            {
                timelineImagesList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in immersiveImages)
            {
                immerseImagesList += eventGalleryImage.Name + ",";
            }
            foreach (EventGalleryImage eventGalleryImage in galleryImages)
            {
                archImagesList += eventGalleryImage.Name + ",";
            }

            resultdata.GalleryImages            = galleryImagesList;
            resultdata.TilesSliderImages        = tilesSliderImagesList;
            resultdata.DescpagebannerImage      = descPageList;
            resultdata.InventorypagebannerImage = inventoryPageList;
            resultdata.PlacemapImages           = plaeMapImagesList;
            resultdata.TimelineImages           = timelineImagesList;
            resultdata.ImmersiveexpImages       = immerseImagesList;
            resultdata.ArchdetailImages         = archImagesList;

            resultdata.Description = eventModel.Description;
            resultdata.Id          = eventModel.Id;
            resultdata.AltId       = eventModel.AltId;
            resultdata.Location    = eventModel.Name;
            List <int> subcatids  = new List <int>();
            List <int> tags       = new List <int>();
            int        categoryId = eventModel.EventCategoryId;

            foreach (var cat in eventcatmap)
            {
                categoryId = cat.EventCategoryId;
                subcatids.Add(cat.EventCategoryId);
            }
            foreach (var tag in eventTags)
            {
                tags.Add((int)tag.TagId);
            }
            var category = _eventCategoryRepository.Get(categoryId);

            resultdata.Subcategoryid = string.Join(",", subcatids);
            resultdata.TagIds        = string.Join(",", tags);
            resultdata.Categoryid    = category.EventCategoryId;
            //resultdata.Subcategoryid = subcatids.FirstOrDefault();

            /*var categorymapobj = eventcatmap.FirstOrDefault();
             * if (categorymapobj != null)
             * {
             *  resultdata.Categoryid = eventModel.EventCategoryId;
             * }*/
            resultdata.Metadescription = eventModel.MetaDetails;
            if (resultdata.Metadescription != null)
            {
                string[] metas = resultdata.Metadescription.Split(new string[] { "<br/>" }, StringSplitOptions.None);
                if (metas.Length == 3)
                {
                    resultdata.Metatitle       = metas[0].Split("title")[1].Replace(">", "").Replace("</", "");
                    resultdata.Metadescription = metas[1].Split("content=")[1].Replace(">", "").Replace("\"", "").Replace("</", "");
                    resultdata.Metatags        = metas[2].Split("content=")[1].Replace(">", "").Replace("\"", "").Replace("</", "");
                }
            }
            resultdata.PlaceName = venuedetail.Name;
            //resultdata.Subcategoryid = eventcatmap.Select(p => p.EventCategoryId).FirstOrDefault();
            //resultdata.Subcategoryid = string.Join(",", eventcatmap.Count() > 0 ? eventcatmap.Select(p => p.EventCategoryId).ToList() : new List<int>());
            resultdata.Title = eventModel.Name;
            var eventHostMappings = _eventHostMappingRepository.GetAllByEventId(eventModel.Id);

            resultdata.EventHostMappings = eventHostMappings.ToList();
            return(resultdata);
        }
        public ActionResult ViewAccProfile()
        {
            int account_id = Convert.ToInt32(Session["Account_Id"].ToString());
            var account    = db.Accounts.SingleOrDefault(x => x.Account_Id == account_id);

            if (account == null)
            {
                return(HttpNotFound());
            }

            var account_interest = db.AccountInterests.Where(x => x.Account_Id.Equals(account.Account_Id)).SingleOrDefault();

            if (account_interest == null)
            {
                account_interest = new AccountInterest();
            }

            List <string> interest_arrs = load_interest(account_interest);

            ViewBag.InterestSelected = interest_arrs;
            AccountQuota account_quota = db.AccountQuotas.SingleOrDefault(x => x.Account_Id == account_id);
            Quota        quota         = new Quota();

            if (account_quota == null)
            {
                account_quota = new AccountQuota();
            }
            else
            {
                quota = account_quota.Quota;
            }

            string district = "";

            if (!string.IsNullOrWhiteSpace(account.AreaCode))
            {
                Zipcode zipcode = db.Zipcodes.SingleOrDefault(x => x.AreaCode.Equals(account.AreaCode));
                if (zipcode != null)
                {
                    district = zipcode.District;
                }
            }

            ViewBag.Quota_Freq_Val = Convert.ToInt16(quota.Quota_Freq_Val);
            ViewBag.Quota_Dur_Val  = Convert.ToInt16(quota.Quota_Dur_Val);

            if (quota.Quota_Cd != null)
            {
                if (quota.Quota_Cd.Equals("Q0001"))
                {
                    ViewBag.Score = 3;
                }
                else
                {
                    if (quota.Quota_Cd.Equals("Q0002"))
                    {
                        ViewBag.Score = 6;
                    }
                    else
                    {
                        if (quota.Quota_Cd.Equals("Q0003"))
                        {
                            ViewBag.Score = 8;
                        }
                        else
                        {
                            ViewBag.Score = 0;
                        }
                    }
                }
            }



            ViewBag.District = district;

            Hashtable quotas = new Hashtable();

            quotas["low"]    = new Hashtable();
            quotas["medium"] = new Hashtable();
            quotas["high"]   = new Hashtable();
            IEnumerable <Quota> base_quotas = db.Quotas.Where(x => x.Quota_Type_Cd.Equals("B")).OrderBy(x => x.Quota_Cd);
            int q_count = 1;

            foreach (var q in base_quotas)
            {
                switch (q_count)
                {
                case 1:
                    quotas["low"] = q;
                    break;

                case 2:
                    quotas["medium"] = q;
                    break;

                case 3:
                    quotas["high"] = q;
                    break;

                default:
                    break;
                }

                q_count += 1;
            }
            ViewBag.Quotas = quotas;
            init_dropdown(account);
            ViewBag.ViewProfile = "true";
            return(View(account));
        }
Exemplo n.º 29
0
 public void AddZipcode(Zipcode zipcode)
 {
     _context.Zipcode.Add(zipcode);
     _context.SaveChanges();
 }
Exemplo n.º 30
0
        public void barCreateStock()
        {
            IngredientController ingredientController = new IngredientController();
            DrinkController      drinkController      = new DrinkController();
            //setup
            Ingredient vodka = new Ingredient
            {
                Name       = "TestVodka",
                Measurable = true,
                Alch       = 37.5
            };

            Ingredient juice = new Ingredient
            {
                Name       = "TestJuice",
                Measurable = false,
                Alch       = 0
            };

            vodka = ingredientController.Create(vodka);
            juice = ingredientController.Create(juice);

            ManagerController mc      = new ManagerController();
            Manager           manager = new Manager("TestName", "TestPhonenumber", "TestEmail", "TestUsername", null);
            Manager           m       = mc.CreateManager(manager, "TestPassword");

            Country country = LocationDB.Instance.getCountryById(1);

            if (country is null)
            {
                Assert.Fail("Country is null");
            }
            Zipcode zip = LocationDB.Instance.findZipById(1);
            Address a   = new Address("TestVej", zip);

            zip.Country = country;
            a.Zipcode   = zip;
            Bar bar = new Bar
            {
                Address     = a,
                Email       = "TestBarEmail",
                Name        = "TestBarName",
                PhoneNumber = "TestBarP",
                Username    = "******"
            };
            Bar Createdbar = controller.Create(bar, m.Id, "TestPassword");

            ICollection <Measurement> measurements = new DrinkController().FindAllMeasurements();
            var allStocks          = controller.GetAllStocks(bar.ID);
            int precount           = allStocks.Count;
            int preVodkaStockCount = allStocks.Where(e => e.Ingredient.Equals(vodka)).Count();
            int preJuiceStockCount = allStocks.Where(e => e.Ingredient.Equals(juice)).Count();

            //act
            controller.CreateStock(Createdbar.ID, 20, vodka, measurements.FirstOrDefault().Id);

            preVodkaStockCount++;   //Just creted one vodka. so we increment
            precount++;             // Just created one more stock in the DB so we increment

            controller.CreateStock(Createdbar.ID, 20, juice, null);
            precount++;           //Just created one juice, so we increment
            preJuiceStockCount++; // Just craeted one juice so we increment

            List <Stock> stocksFound = controller.GetAllStocks(bar.ID);
            //assert
            bool success = (stocksFound.Where(e => e.Ingredient.Equals(vodka))).Count() == preVodkaStockCount &&
                           stocksFound.Count() == precount;


            Assert.IsTrue(success, "Stock measurable was not created successfully");
            int actual = stocksFound.Where(e => e.Ingredient.Equals(juice)).Count();


            success = (actual == preJuiceStockCount && stocksFound.Count() == precount);

            Assert.IsTrue(success, "Stock not mreasurable was not created successfully");
        }
Exemplo n.º 31
0
        protected override async Task <ICommandResult> Handle(PaymentCommand query)
        {
            var  transaction = _transactionRepository.Get(query.TransactionId);
            var  currency    = _currencyTypeRepository.Get(transaction.CurrencyId);
            User user        = _userRepository.GetByEmail(transaction.EmailId);

            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(query.PaymentCard.CardNumber, user.Id);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = user.Id,
                    AltId       = new Guid(),
                    NameOnCard  = query.PaymentCard.NameOnCard ?? string.Empty,
                    CardNumber  = query.PaymentCard.CardNumber ?? string.Empty,
                    ExpiryMonth = query.PaymentCard.ExpiryMonth,
                    ExpiryYear  = query.PaymentCard.ExpiryYear,
                    CardTypeId  = query.PaymentCard.CardType
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            try
            {
                if (query.BillingAddress != null)
                {
                    if (query.BillingAddress.Zipcode == null)
                    {
                        query.BillingAddress.Zipcode = "110016";
                    }

                    var zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    if (zipcode == null)
                    {
                        var city    = _cityRepository.GetByName(query.BillingAddress.City);
                        var zipCode = new Zipcode
                        {
                            AltId      = Guid.NewGuid(),
                            Postalcode = query.BillingAddress.Zipcode.ToString(),
                            CityId     = city != null ? city.Id : 0,
                            IsEnabled  = true
                        };

                        _zipcodeRepository.Save(zipCode);

                        zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString());
                    }
                    if (user != null && zipcode != null)
                    {
                        var addressDetail = new UserAddressDetail
                        {
                            UserId        = user.Id,
                            AltId         = Guid.NewGuid(),
                            FirstName     = user.FirstName,
                            LastName      = user.LastName,
                            PhoneCode     = user.PhoneCode,
                            PhoneNumber   = user.PhoneNumber,
                            AddressLine1  = query.BillingAddress.Address,
                            Zipcode       = zipcode.Id,
                            AddressTypeId = AddressTypes.Billing,
                            IsEnabled     = true
                        };

                        _userAddressDetailRepository.Save(addressDetail);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            if (query.PaymentGateway != null)
            {
                List <FIL.Contracts.DataModels.TransactionDetail> transactionDetails = _transactionDetailRepository.GetByTransactionId(transaction.Id).ToList();
                if (transactionDetails.Any())
                {
                    List <FIL.Contracts.DataModels.TransactionSeatDetail> transactionSeatDetails = _transactionSeatDetailRepository.GetByTransactionDetailIds(transactionDetails.Select(s => s.Id)).ToList();
                    if (transactionSeatDetails != null)
                    {
                        var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByMatchSeatTicketDetailIds(transactionSeatDetails.Select(s => s.MatchSeatTicketDetailId)).ToList();

                        if (matchSeatTicketDetail != null && matchSeatTicketDetail.Any())
                        {
                            return(new PaymentCommandResult
                            {
                                TransactionAltId = transaction.AltId,
                                PaymentResponse = new PaymentResponse
                                {
                                    Success = false,
                                    PaymentGatewayError = PaymentGatewayError.Unknown
                                }
                            });
                        }
                    }
                }
            }

            if (query.PaymentGateway == PaymentGateway.Stripe)
            {
                bool isIntentConfirm = false;
                if (query.PaymentCard.NameOnCard != null)
                {
                    isIntentConfirm = query.PaymentCard.NameOnCard.Equals("intent", StringComparison.InvariantCultureIgnoreCase);
                }
                var paymentResponse = await _stripeCharger.Charge(new StripeCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    Token            = query.Token,
                    ChannelId        = query.ChannelId,
                    IsIntentConfirm  = isIntentConfirm
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = paymentResponse
                });
            }

            if (query.PaymentGateway != null && query.PaymentGateway == PaymentGateway.NabTransact)
            {
                var paymentHtmlPostResponse = await _nabTransactCharger.Charge(new NabTransactCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName    = user.FirstName,
                        LastName     = user.LastName,
                        PhoneCode    = user.PhoneCode,
                        PhoneNumber  = user.PhoneNumber,
                        Email        = user.Email,
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "3032",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    PaymentOption = PaymentOptions.CreditCard,
                    User          = new FIL.Contracts.Models.User
                    {
                        Email = user.Email
                    },
                    //IPAddress = ipDetail.IPAddress
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            if (PaymentOptions.CreditCard == query.PaymentOption || PaymentOptions.DebitCard == query.PaymentOption)
            {
                IHdfcEnrollmentResponse hdfcEnrollmentResponse = _hdfcChargerResolver.HdfcEnrollmentVerification(new HdfcCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    }
                });

                if (hdfcEnrollmentResponse.PaymentGatewayError == PaymentGatewayError.None)
                {
                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "ENROLLED")
                    {
                        var paymentHtmlPostResponse = await _hdfcPaymentHtmlPostCharger.Charge(hdfcEnrollmentResponse.HdfcEnrolledCharge);

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentHtmlPostResponse = paymentHtmlPostResponse
                        });
                    }

                    if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "NOT ENROLLED")
                    {
                        var paymentResponse = await _hdfcCharger.Charge(new HdfcCharge
                        {
                            TransactionId    = transaction.Id,
                            Currency         = currency.Code,
                            Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                            UserCardDetailId = userCardDetail.Id,
                            PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                            {
                                CardNumber  = query.PaymentCard.CardNumber,
                                NameOnCard  = query.PaymentCard.NameOnCard,
                                Cvv         = query.PaymentCard.Cvv,
                                ExpiryMonth = query.PaymentCard.ExpiryMonth,
                                ExpiryYear  = query.PaymentCard.ExpiryYear,
                                CardType    = query.PaymentCard.CardType
                            }
                        });

                        return(new PaymentCommandResult
                        {
                            TransactionAltId = transaction.AltId,
                            PaymentResponse = paymentResponse
                        });
                    }
                }

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentResponse = new PaymentResponse
                    {
                        Success = false,
                        PaymentGatewayError = hdfcEnrollmentResponse.PaymentGatewayError
                    }
                });
            }

            if (PaymentOptions.NetBanking == query.PaymentOption || PaymentOptions.CashCard == query.PaymentOption)
            {
                var paymentHtmlPostResponse = await _ccavenuePaymentHtmlPostCharger.Charge(new CcavenueCharge
                {
                    TransactionId    = transaction.Id,
                    Currency         = currency.Code,
                    Amount           = Convert.ToDecimal(transaction.NetTicketAmount),
                    UserCardDetailId = userCardDetail.Id,
                    PaymentCard      = new FIL.Contracts.Models.PaymentChargers.PaymentCard
                    {
                        CardNumber  = query.PaymentCard.CardNumber,
                        NameOnCard  = query.PaymentCard.NameOnCard,
                        Cvv         = query.PaymentCard.Cvv,
                        ExpiryMonth = query.PaymentCard.ExpiryMonth,
                        ExpiryYear  = query.PaymentCard.ExpiryYear,
                        CardType    = query.PaymentCard.CardType
                    },
                    PaymentOption  = (PaymentOptions)query.PaymentOption,
                    BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress
                    {
                        FirstName   = !string.IsNullOrWhiteSpace(transaction.FirstName) ? transaction.FirstName : "Zoonga",
                        LastName    = !string.IsNullOrWhiteSpace(transaction.LastName) ? transaction.LastName : "Zoonga",
                        PhoneCode   = !string.IsNullOrWhiteSpace(transaction.PhoneCode) ? transaction.PhoneCode : "91",
                        PhoneNumber = !string.IsNullOrWhiteSpace(transaction.PhoneNumber) ? transaction.PhoneNumber : "9899704772",
                        Email       = !string.IsNullOrWhiteSpace(transaction.EmailId) ? transaction.EmailId : "*****@*****.**",
                        //FirstName = "Gaurav",
                        //LastName = "Bhardwaj",
                        //PhoneCode = "91",
                        //PhoneNumber = "9899704772",
                        //Email = "*****@*****.**",
                        AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga",
                        Zipcode      = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "110016",
                        City         = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi",
                        State        = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi",
                        Country      = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India"
                    },
                    BankAltId = query.BankAltId,
                    CardAltId = query.CardAltId,
                    ChannelId = query.ChannelId,
                });

                return(new PaymentCommandResult
                {
                    TransactionAltId = transaction.AltId,
                    PaymentHtmlPostResponse = paymentHtmlPostResponse
                });
            }

            return(new PaymentCommandResult
            {
                TransactionAltId = transaction.AltId,
                PaymentResponse = new PaymentResponse
                {
                    Success = false,
                    PaymentGatewayError = PaymentGatewayError.Unknown
                }
            });
        }
Exemplo n.º 32
0
        private void FillDataToTheDataBase()
        {
            #region Make bar
            BarController     bc      = new BarController();
            ManagerController mc      = new ManagerController();
            Manager           manager = new Manager("TestName", "TestPhonenumber", "TestEmail", "TestUsername", null);
            Manager           m       = mc.CreateManager(manager, "TestPassword");

            Country country = LocationDB.Instance.getCountryById(1);
            if (country is null)
            {
                Assert.Fail("Country is null");
            }
            Zipcode zip = LocationDB.Instance.findZipById(1);
            Address a   = new Address("TestVej", zip);
            zip.Country = country;
            a.Zipcode   = zip;

            Bar bar = new Bar
            {
                Address     = a,
                Email       = "TestBarEmail",
                Name        = "TestBarName",
                PhoneNumber = "TestBarP",
                Username    = "******"
            };
            this.bar = bc.Create(bar, m.Id, "TestPassword");
            #endregion

            IngredientController ingredientController = new IngredientController();

            List <Drink> drinks = new List <Drink>();


            Ingredient vodka = new Ingredient
            {
                Name       = "TestVodka",
                Measurable = true,
                Alch       = 37.5
            };

            Ingredient juice = new Ingredient
            {
                Name       = "TestJuice",
                Measurable = true,
                Alch       = 0
            };

            TestVodkaIngre = ingredientController.Create(vodka);
            TestJuiceIngre = ingredientController.Create(juice);


            quantifiedIngredientVodka = new QuantifiedIngredient
            {
                Quantity    = 6,
                Ingredient  = ingredientController.Find("TestVodka").First(), //We would like it to throw an exception here, as it's a test
                Measurement = ingredientController.FindMeasurement("cl")
            };

            quantifiedIngredientJuice = new QuantifiedIngredient
            {
                Quantity    = 2,
                Ingredient  = ingredientController.Find("TestJuice").First(), //We would like it to throw an exception here, as it's a test
                Measurement = ingredientController.FindMeasurement("cl")
            };

            Drink drinkVodkaJuice = new Drink
            {
                Recipe = "TestVodkaJuiceRecipe",
                Names  = new List <string>()
                {
                    "TestName1", "TestName2"
                },
                Ingredients = new List <QuantifiedIngredient>()
                {
                    quantifiedIngredientJuice, quantifiedIngredientVodka
                }
            };

            Drink drinkVodka = new Drink
            {
                Recipe = "TestVodkaRecipe",
                Names  = new List <string>()
                {
                    "TestNameVodka"
                },
                Ingredients = new List <QuantifiedIngredient>()
                {
                    quantifiedIngredientVodka
                }
            };

            Drink drinkJuice = new Drink
            {
                Recipe = "TestJuiceRecipe",
                Id     = 3,
                Names  = new List <string>()
                {
                    "TestJuice", "TestAppelsinjuice"
                },
                Ingredients = new List <QuantifiedIngredient>()
                {
                    quantifiedIngredientJuice
                }
            };

            TestVodka      = controller.Create(drinkVodka);
            TestJuice      = controller.Create(drinkJuice);
            TestVodkaJuice = controller.Create(drinkVodkaJuice);
        }
Exemplo n.º 33
0
        public Zipcode SelectOne(int id)
        {
            Zipcode selectedZip = _zipcodes.Where(z => z.ZipCodeID == id).FirstOrDefault();

            return(selectedZip);
        }