public Warehouse SaveInfo()
        {
            Warehouse warehouse = this.WarehouseService.GetWarehouseById(this.WarehouseId);

            if (warehouse != null)
            {
                warehouse.Name = txtName.Text;
                warehouse.PhoneNumber = txtPhoneNumber.Text;
                warehouse.Email = txtEmail.Text;
                warehouse.FaxNumber = txtFaxNumber.Text;
                warehouse.Address1 = txtAddress1.Text;
                warehouse.Address2 = txtAddress2.Text;
                warehouse.City = txtCity.Text;
                warehouse.StateProvince = txtStateProvince.Text;
                warehouse.ZipPostalCode = txtZipPostalCode.Text;
                warehouse.CountryId = int.Parse(this.ddlCountry.SelectedItem.Value);
                warehouse.UpdatedOn = DateTime.UtcNow;

                this.WarehouseService.UpdateWarehouse(warehouse);

            }
            else
            {
                DateTime now = DateTime.UtcNow;
                warehouse = new Warehouse()
                {
                    Name = txtName.Text,
                    PhoneNumber = txtPhoneNumber.Text,
                    Email = txtEmail.Text,
                    FaxNumber = txtFaxNumber.Text,
                    Address1 = txtAddress1.Text,
                    Address2 = txtAddress2.Text,
                    City = txtCity.Text,
                    StateProvince = txtStateProvince.Text,
                    ZipPostalCode = txtZipPostalCode.Text,
                    CountryId = int.Parse(this.ddlCountry.SelectedItem.Value),
                    CreatedOn = now,
                    UpdatedOn = now
                };
                this.WarehouseService.InsertWarehouse(warehouse);
            }

            return warehouse;
        }
示例#2
0
        /// <summary>
        /// Inserts a warehouse
        /// </summary>
        /// <param name="warehouse">Warehouse</param>
        public void InsertWarehouse(Warehouse warehouse)
        {
            if (warehouse == null)
                throw new ArgumentNullException("warehouse");

            warehouse.Name = CommonHelper.EnsureNotNull(warehouse.Name);
            warehouse.Name = CommonHelper.EnsureMaximumLength(warehouse.Name, 255);
            warehouse.PhoneNumber = CommonHelper.EnsureNotNull(warehouse.PhoneNumber);
            warehouse.PhoneNumber = CommonHelper.EnsureMaximumLength(warehouse.PhoneNumber, 50);
            warehouse.Email = CommonHelper.EnsureNotNull(warehouse.Email);
            warehouse.Email = CommonHelper.EnsureMaximumLength(warehouse.Email, 255);
            warehouse.FaxNumber = CommonHelper.EnsureNotNull(warehouse.FaxNumber);
            warehouse.FaxNumber = CommonHelper.EnsureMaximumLength(warehouse.FaxNumber, 50);
            warehouse.Address1 = CommonHelper.EnsureNotNull(warehouse.Address1);
            warehouse.Address1 = CommonHelper.EnsureMaximumLength(warehouse.Address1, 100);
            warehouse.Address2 = CommonHelper.EnsureNotNull(warehouse.Address2);
            warehouse.Address2 = CommonHelper.EnsureMaximumLength(warehouse.Address2, 100);
            warehouse.City = CommonHelper.EnsureNotNull(warehouse.City);
            warehouse.City = CommonHelper.EnsureMaximumLength(warehouse.City, 100);
            warehouse.StateProvince = CommonHelper.EnsureNotNull(warehouse.StateProvince);
            warehouse.StateProvince = CommonHelper.EnsureMaximumLength(warehouse.StateProvince, 100);
            warehouse.ZipPostalCode = CommonHelper.EnsureNotNull(warehouse.ZipPostalCode);
            warehouse.ZipPostalCode = CommonHelper.EnsureMaximumLength(warehouse.ZipPostalCode, 30);

            _context.Warehouses.AddObject(warehouse);
            _context.SaveChanges();
        }