コード例 #1
0
        // POST: api/Employee
        public string Post([FromBody]RegEmployee RegEmp)
        {
            foreach (var item in EmpMang.GetAllEmployees())
            {
                if (item.EmailID.Equals(RegEmp.EmailID))
                    return "Username already registered";
            }

            Rideally.Entities.Employee emp = new Rideally.Entities.Employee();
            Rideally.Entities.Address home = new Entities.Address();
            Rideally.Entities.Address office = new Entities.Address();
            home.Latitude = RegEmp.HomeLatitude;      home.Longitude = RegEmp.HomeLongitude;       home.type = true;
            office.Latitude = RegEmp.OfficeLatitude;  office.Longitude = RegEmp.OfficeLongitude;   office.type = false;
            emp.HomeAddress = home; emp.OfficeAddress = office;

            Rideally.Entities.Authentication auth = new Entities.Authentication();
            auth.Login = RegEmp.EmailID;
            string password = "******";// System.Web.Security.Membership.GeneratePassword(8, 0);
            auth.Password = Rideally.Util.SaltHash.ComputeHash(password, null, null);
            Rideally.Util.Email.SendMail(RegEmp.EmailID, "RideAlly User Password", "Your password for RideAlly = " + password);
            
            emp.UserAuthentication = auth;
            emp.EmployeeName = RegEmp.EmployeeName;

            emp.Gender = RegEmp.Gender;
            emp.MobileNo = RegEmp.MobileNo;
            emp.EmailID = RegEmp.EmailID;
            return EmpMang.AddEmployee(emp).ToString();
        }
コード例 #2
0
        public async Task <GeocodeResponse> GetLocationInfoAsync(Entities.Address address)
        {
            var request = new HttpRequestMessage(HttpMethod.Get,
                                                 _options.GeocodeBaseUrl
                                                 + address.StreetNo + "+"
                                                 + address.StreetName + "+"
                                                 + address.City + "&apiKey="
                                                 + _options.HereApikey);

            var client = _client.CreateClient();

            var response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                var result = await response.Content.ReadAsStringAsync();

                var JsonResult = JsonConvert.DeserializeObject <GeocodeResponse>(result);
                this.Error = !JsonResult.Items.Any();
                return(JsonResult);
            }
            else
            {
                throw new ArgumentException("Something went wrong while fetching geocode!");
            }
        }
コード例 #3
0
        public async Task Handle_ExistingCustomerAndAddress_DeleteCustomerAddress(
            [Frozen] Entities.Customer customer,
            [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
            DeleteCustomerAddressCommandHandler sut,
            DeleteCustomerAddressCommand command,
            Entities.Address address
            )
        {
            //Arrange
            customer.AddAddress(
                new Entities.CustomerAddress(
                    command.AddressType,
                    address
                    )
                );

            customerRepoMock.Setup(x => x.GetBySpecAsync(
                                       It.IsAny <GetCustomerSpecification>(),
                                       It.IsAny <CancellationToken>()
                                       ))
            .ReturnsAsync(customer);

            //Act
            var result = await sut.Handle(command, CancellationToken.None);

            //Assert
            result.Should().NotBeNull();
            customerRepoMock.Verify(x => x.UpdateAsync(
                                        It.IsAny <Entities.Customer>(),
                                        It.IsAny <CancellationToken>()
                                        ));
        }
コード例 #4
0
        public List <Address.Business.Entities.Address> Address_CheckExists(string A_ParentID, int A_Level, string A_Center)
        {
            _dbAdapter.ResetParams();
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_ParentID", A_ParentID);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_Level", A_Level);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_Center", A_Center);

            List <Entities.Address> address = new List <Entities.Address>();
            SqlDataReader           reader  = _dbAdapter.Select("Address_CheckExists");

            Entities.Address child = null;
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    child         = new Entities.Address();
                    child.A_ID    = reader["A_ID"].ToString();
                    child.A_Level = int.Parse(reader["A_Level"].ToString());
                    child.A_Name  = (string)reader["A_Name"];
                    address.Add(child);
                }
            }
            reader.Close();

            return(address);
        }
コード例 #5
0
        /// <summary>
        /// Lấy thông tin chi tiết của một địa chỉ đã bao gồm cả lịch sử
        /// </summary>
        /// <param name="AddressID"></param>
        /// <returns></returns>
        public Entities.Address Address_GetDetailWithHistory(string AddressID, string UserID)
        {
            _dbAdapter.ResetParams();
            _dbAdapter.AddParam(SqlDbType.VarChar, "@AddressID", AddressID);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@UserID", UserID);
            Entities.Address address = null;
            SqlDataReader    reader  = _dbAdapter.Select("Address_GetDetailWithHistory");

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    address      = new Entities.Address();
                    address.A_ID = reader["A_ID"].ToString();
                    //address.A_Center = reader["A_Center"].ToString();
                    address.A_ParentID       = reader["A_ParentID"].ToString();
                    address.A_Level          = int.Parse(reader["A_Level"].ToString());
                    address.A_Name           = (string)reader["A_Name"];
                    address.A_Description    = reader["A_Description"] != DBNull.Value ? (string)reader["A_Description"] : string.Empty;
                    address.A_CreatedByUser  = reader["A_CreatedByUser"] != DBNull.Value ? (string)reader["A_CreatedByUser"] : string.Empty;
                    address.A_CreatedOnDate  = reader["A_CreatedOnDate"] != DBNull.Value ? DateTime.Parse(reader["A_CreatedOnDate"].ToString()) : DateTime.MinValue;
                    address.A_ReviewedByUser = reader["A_ReviewedByUser"] != DBNull.Value ? (string)reader["A_ReviewedByUser"] : string.Empty;
                    address.A_ReviewedOnDate = reader["A_ReviewedOnDate"] != DBNull.Value ? DateTime.Parse(reader["A_ReviewedOnDate"].ToString()) : DateTime.MinValue;
                    address.A_Status         = int.Parse(reader["A_Status"].ToString());
                }
            }

            reader.NextResult();
            address.A_History = new List <History>();
            History history = null;

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    history             = new History();
                    history.H_ID        = reader["H_ID"].ToString();
                    history.H_AddressID = reader["H_AddressID"].ToString();
                    history.H_ParentID  = reader["H_ParentID"].ToString();

                    history.H_Level          = int.Parse(reader["H_Level"].ToString());
                    history.H_Name           = (string)reader["H_Name"];
                    history.H_Description    = reader["H_Description"] != DBNull.Value ? (string)reader["H_Description"] : string.Empty;
                    history.H_CreatedByUser  = reader["H_CreatedByUser"] != DBNull.Value ? (string)reader["H_CreatedByUser"] : string.Empty;
                    history.H_CreatedOnDate  = reader["H_CreatedOnDate"] != DBNull.Value ? DateTime.Parse(reader["H_CreatedOnDate"].ToString()) : DateTime.MinValue;
                    history.H_ModifiedOnDate = reader["H_ModifiedOnDate"] != DBNull.Value ? DateTime.Parse(reader["H_ModifiedOnDate"].ToString()) : DateTime.MinValue;
                    history.H_Action         = reader["H_Action"] != DBNull.Value ? (string)reader["H_Action"] : string.Empty;
                    history.H_ActionDetail   = reader["H_ActionDetail"] != DBNull.Value ? (string)reader["H_ActionDetail"] : string.Empty;
                    history.H_Rate           = reader["H_Rate"] != DBNull.Value ? (int)reader["H_Rate"] : 0;
                    history.H_Status         = int.Parse(reader["H_Status"].ToString());
                    history.H_IsRestore      = int.Parse(reader["H_IsRestore"].ToString());
                    history.H_IsOwner        = int.Parse(reader["H_IsOwner"].ToString());
                    address.A_History.Add(history);
                }
            }
            reader.Close();
            return(address);
        }
コード例 #6
0
        public static Operations.DataStructures.Address ToServiceContract(Entities.Address addressEntity)
        {
            if (addressEntity == null)
            {
                return(null);
            }

            return(new Operations.DataStructures.Address(addressEntity.Country, addressEntity.State, addressEntity.City, addressEntity.Zip, addressEntity.Street, addressEntity.House));
        }
コード例 #7
0
 private void PickDestAddressBtn_Click(object sender, EventArgs e)
 {
     addressList.ShowDialog();
     Entities.Address addr = addressList.SelectedAddress;
     if (addr != null)
     {
         destinationTextBox.Text = addr.ToString();
     }
 }
コード例 #8
0
 public AddressForm(Guid id)
 {
     currentAddress = Repositories.Addresses.Read(id);
     if (currentAddress == null)
     {
         currentAddress = new Entities.Address("Example");
     }
     InitializeComponent();
 }
コード例 #9
0
        private void OnAddressBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
        {
            _currentAddress = uxAddressBindingSource.Current as Entities.Address;

            if (_currentAddress != null)
            {
                _currentAddress.Validate();
            }
            //_Address.Validate();
            OnCurrentEntityChanged();
        }
コード例 #10
0
        public List <Entities.Address> Parse(List <HotelBookingSystemDataOperations.Address> hotelData)
        {
            List <Entities.Address> addresses = new List <Entities.Address>();

            foreach (HotelBookingSystemDataOperations.Address address in hotelData)
            {
                Entities.Address newAddress = new Entities.Address();
                newAddress.City     = address.City;
                newAddress.Locality = address.Locality;
            }
            return(addresses);
        }
コード例 #11
0
 public Task <object> Handle(UpdateCustomerCommand command, CancellationToken cancellationToken)
 {
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         AddressModel addressModel = _AddressRepository.GetByLatLng(command.Lat, command.Lng);
         if (addressModel == null)
         {
             Entities.Address address = new Entities.Address(
                 null,
                 new City(command.City),
                 new Country(command.Country),
                 new District(command.District),
                 new Lat(command.Lat),
                 new Lng(command.Lng),
                 new Street(command.Street),
                 new StreetNumber(command.StreetNumber)
                 );
             addressModel = _AddressRepository.Add(address);
         }
         Entities.Customer u = new Entities.Customer(
             new Identity((uint)command.Id),
             new Name(command.Name),
             new Note(command.Note),
             new CartCode(command.CartCode),
             new PhoneNumber(command.PhoneNumber),
             new Email(command.Email),
             new Code(command.Code),
             new Status(command.Status),
             new Entities.Address(
                 new Identity((uint)addressModel.ID),
                 new City(command.City),
                 new Country(command.Country),
                 new District(command.District),
                 new Lat(command.Lat),
                 new Lng(command.Lng),
                 new Street(command.Street),
                 new StreetNumber(command.StreetNumber)
                 )
             );
         bool resullt = _CustomerRepository.Update(u);
         if (!resullt)
         {
             _bus.RaiseEvent(new DomainNotification("Customer", "Server error", NotificationCode.Error));
         }
         return(Task.FromResult(resullt as object));
     }
     return(Task.FromResult(false as object));
 }
コード例 #12
0
        /// <summary>
        /// Thêm mới địa chỉ, kiem tra user chua ton tai cung them vao luon
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public bool Address_Add(Entities.Address address)
        {
            _dbAdapter.ResetParams();
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_Center", address.A_Center);
            _dbAdapter.AddParam(SqlDbType.NVarChar, "@A_Border", address.A_Border);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_ParentID", address.A_ParentID);
            _dbAdapter.AddParam(SqlDbType.TinyInt, "@A_Level", address.A_Level);
            _dbAdapter.AddParam(SqlDbType.NVarChar, "@A_Name", address.A_Name);
            _dbAdapter.AddParam(SqlDbType.NVarChar, "@A_Description", address.A_Description);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_CreatedByUser", address.A_CreatedByUser);

            return(_dbAdapter.Insert("Address_Add"));
        }
コード例 #13
0
        public Address(Entities.Address address)
        {
            this.AddressId = address.AddressId;

            if (address.User != null)
            {
                this.User = new Models.User(address.User);
            }

            this.Street   = address.Street;
            this.City     = address.City;
            this.Country  = address.Country;
            this.Passcode = address.Passcode;
        }
コード例 #14
0
        public void RemoveRelPhoneAddress(AddressPhoneModel model)
        {
            var address = new Entities.Address {
                AddressId = model.AddressId
            };
            var phone = new ClientPhone {
                ClientPhoneId = model.AddressPhoneId
            };

            address.ClientPhone.Add(phone);
            DbEntities.Address.Attach(address);
            address.ClientPhone.Remove(phone);
            DbEntities.SaveChanges();
        }
コード例 #15
0
 public static Entities.Address Update(Entities.Address address)
 {
     try
     {
         int index = collection.IndexOf(collection.Where(addr => addr.id == address.id).FirstOrDefault());
         collection.RemoveAt(index);
         collection.Insert(index - 1, address);
         return(Read(address.id));
     } catch (ArgumentOutOfRangeException)
     {
         collection.Add(address);
         return(address);
     }
 }
コード例 #16
0
        /// <summary>
        /// Lấy danh sách các địa chỉ theo id cha và chi tiết thông tin địa chỉ của id cha (ko bao gồm lịch sử)
        /// </summary>
        /// <param name="AddressID"></param>
        /// <returns></returns>
        public Entities.Address Address_GetDetailWithChildren(string AddressID)
        {
            _dbAdapter.ResetParams();
            _dbAdapter.AddParam(SqlDbType.VarChar, "@AddressID", AddressID);

            Entities.Address address = null;
            SqlDataReader    reader  = _dbAdapter.Select("Address_GetDetailWithChildren");

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    address               = new Entities.Address();
                    address.A_ID          = reader["A_ID"].ToString();
                    address.A_Center      = reader["A_Center"].ToString();
                    address.A_ParentID    = reader["A_ParentID"].ToString();
                    address.A_Level       = int.Parse(reader["A_Level"].ToString());
                    address.A_Name        = (string)reader["A_Name"];
                    address.A_Description = reader["A_Description"] != DBNull.Value ? (string)reader["A_Description"] : string.Empty;
                }
            }
            reader.NextResult();
            address.Points = new List <string>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    address.Points.Add((string)reader["LongLat"]);
                }
                //reader.Close();
            }
            reader.NextResult();
            address.A_Children = new List <Entities.Address>();
            Entities.Address child = null;
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    child               = new Entities.Address();
                    child.A_ID          = reader["A_ID"].ToString();
                    child.A_Level       = int.Parse(reader["A_Level"].ToString());
                    child.A_Name        = (string)reader["A_Name"];
                    child.A_Description = reader["A_Description"] != DBNull.Value ? (string)reader["A_Description"] : string.Empty;
                    address.A_Children.Add(child);
                }
            }
            reader.Close();
            return(address);
        }
コード例 #17
0
        public Entities.Address GenerateAddressValid()
        {
            var address = new Entities.Address()
            {
                CustomerID = Guid.NewGuid(),
                AddressID  = Guid.NewGuid(),
                City       = "São Paulo",
                Country    = "Brasil",
                Number     = 14,
                State      = "São Paulo",
                Street     = "Rua Fulano de Tal",
                Zipcode    = "1111111"
            };

            return(address);
        }
コード例 #18
0
        public Entities.Address GenerateAddressInvalid()
        {
            var address = new Entities.Address()
            {
                CustomerID = Guid.Empty,
                AddressID  = Guid.Empty,
                City       = "São",
                Country    = "Br",
                Number     = 1,
                State      = "São",
                Street     = "Rua",
                Zipcode    = "1111111"
            };

            return(address);
        }
コード例 #19
0
 private void ViewAddressBookBtn_Click(object sender, EventArgs e)
 {
     addressList.ShowDialog();
     Entities.Address addr = addressList.SelectedAddress;
     if (addr != null)
     {
         AorBForm ab = new AorBForm("Source", "Destination");
         ab.ShowDialog();
         if (ab.selectedOption == "Source")
         {
             sourceTextBox.Text = addr.ToString();
         }
         else
         {
             destinationTextBox.Text = addr.ToString();
         }
     }
 }
コード例 #20
0
        public ResultValidate Address_AddValidate(Entities.Address add)
        {
            _dbAdapter.ResetParams();
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_ID", add.A_ID);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_Center", add.A_Center);
            _dbAdapter.AddParam(SqlDbType.NVarChar, "@A_Border", add.A_Border);
            _dbAdapter.AddParam(SqlDbType.VarChar, "@A_ParentID", add.A_ParentID);
            _dbAdapter.AddParam(SqlDbType.TinyInt, "@A_Level", add.A_Level);
            _dbAdapter.AddParam(SqlDbType.NVarChar, "@A_Name", add.A_Name);

            Entities.ResultValidate result = null;
            SqlDataReader           reader = _dbAdapter.Select("Address_AddValidate");

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    result = new Entities.ResultValidate();
                    result.DuongBaoHopLe            = int.Parse(reader["DuongBaoHopLe"].ToString());
                    result.DiemNamTrongDuongBao     = int.Parse(reader["DiemNamTrongDuongBao"].ToString());
                    result.DuongBaoNamTrongDuongBao = int.Parse(reader["DuongBaoNamTrongDuongBao"].ToString());
                }
            }
            reader.NextResult();
            result.DiaDanhTrung = new List <Entities.Address>();
            Entities.Address address = null;
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    address                 = new Entities.Address();
                    address.A_ID            = reader["A_ID"].ToString();
                    address.A_Name          = (string)reader["A_Name"];
                    address.A_Description   = reader["A_Description"] != DBNull.Value ? (string)reader["A_Description"] : string.Empty;
                    address.A_CreatedByUser = reader["A_CreatedByUser"] != DBNull.Value ? (string)reader["A_CreatedByUser"] : string.Empty;
                    address.A_CreatedOnDate = reader["A_CreatedOnDate"] != DBNull.Value ? DateTime.Parse(reader["A_CreatedOnDate"].ToString()) : DateTime.MinValue;
                    address.A_Status        = int.Parse(reader["A_Status"].ToString());
                    result.DiaDanhTrung.Add(address);
                }
            }
            reader.Close();
            return(result);
        }
コード例 #21
0
        private void UpdateSelectedAddressFromDataGrid(int rowIndex)
        {
            Guid        id    = Guid.Parse(AddressListDataTable[0, rowIndex].Value.ToString());
            AddressForm objUI = new AddressForm(id);

            objUI.ShowDialog();
            try
            {
                AddressListDataTable.Rows.RemoveAt(rowIndex);
                Entities.Address addr = Repositories.Addresses.Read(id);
                AddressListDataTable.Rows.Insert(rowIndex - 1, addr.ToArray());
            } catch (ArgumentOutOfRangeException)
            {
                Entities.Address addr  = Repositories.Addresses.Read(id);
                List <string>    cells = addr.ToArray().ToList();
                cells.Add("Edit");
                cells.Add("Delete");
                cells.Add("Select");
                AddressListDataTable.Rows.Add(cells.ToArray());
            }
        }
コード例 #22
0
        public void GetEntries()
        {
            List <ShowEntriesResponseModel> responseList        = new List <ShowEntriesResponseModel>();
            List <Entities.Property>        workingPropertyList = _propertyCRUD.GetAllProperties();

            foreach (var property in workingPropertyList)
            {
                ShowEntriesResponseModel showEntriesResponseModel = new ShowEntriesResponseModel();
                showEntriesResponseModel.EstimatedPrice = property.EstimatedPrice;

                Entities.Case workingCase = _caseCRUD.ReadCase(property.CaseID);

                if (workingCase.Realtor != null)
                {
                    showEntriesResponseModel.RealtorID = workingCase.Realtor.RealtorID;
                }

                if (workingCase.ClosedDate != null)
                {
                    showEntriesResponseModel.ClosedDate = workingCase.ClosedDate;
                }

                showEntriesResponseModel.Price = workingCase.Price;


                Entities.Address workingAddress = _addressCRUD.ReadAddress(property.PostalCode, property.AddressLine1);

                showEntriesResponseModel.PostalCode    = workingAddress.PostalCode;
                showEntriesResponseModel.AddressLine1  = workingAddress.AddressLine1;
                showEntriesResponseModel.AddressLine2  = workingAddress.AddressLine2;
                showEntriesResponseModel.OwnershipCost = workingAddress.OwnershipCost;
                showEntriesResponseModel.ExteriorArea  = workingAddress.ExteriorArea;
                showEntriesResponseModel.InteriorArea  = workingAddress.InteriorArea;
                showEntriesResponseModel.BuildYear     = workingAddress.BuildYear;
                responseList.Add(showEntriesResponseModel);

                _showEntryOutput.DisplayListOfEntries(responseList);
            }
        }
コード例 #23
0
        public async Task <ActionResult <Models.Address> > AddAddressForUser(Models.Address model)
        {
            try
            {
                var user = this.GetUser();
                if (user == null)
                {
                    return(NotFound(new { message = "User Not Found " }));
                }

                Entities.Address address = new Entities.Address()
                {
                    Street   = model.Street,
                    City     = model.City,
                    Country  = model.Country,
                    Passcode = model.Passcode,
                    User     = user,
                };

                await this._dbContext.Addresses.AddAsync(address);

                int result = await this._dbContext.SaveChangesAsync();

                if (result > 0)
                {
                    return(Ok(new Models.Address(address)));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                this._logger.LogError(ex, $"AddAddressForUser Failed");
                return(BadRequest());
            }
        }
コード例 #24
0
        public long Add(AddressModel model)
        {
            var address = new Entities.Address
            {
                MainAddress  = model.MainAddress,
                ExtIntNumber = model.NumExt,
                Reference    = model.Reference,
                RegionArId   = model.RegionArId,
                RegionBrId   = model.RegionBrId,
                RegionCrId   = model.RegionCrId,
                RegionDrId   = model.RegionDrId,
                ZipCodeId    = model.ZipCodeId
            };

            if (model.CountryId != null)
            {
                address.CountryId = model.CountryId.Value;
            }

            DbEntities.Address.Add(address);
            DbEntities.SaveChanges();
            return(address.AddressId);
        }
コード例 #25
0
            public async Task GetPreferredBillingAddress_HomeAddressExists_ReturnAddress(
                [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
                GetPreferredAddressQueryHandler sut,
                GetPreferredAddressQuery query,
                Entities.IndividualCustomer customer,
                Entities.Address address
                )
            {
                //Arrange
                query.AddressType = "Billing";
                customer.AddAddress(
                    new Entities.CustomerAddress(
                        "Home",
                        address
                        )
                    );

                customerRepoMock.Setup(_ => _.GetBySpecAsync(
                                           It.IsAny <GetCustomerAddressesSpecification>(),
                                           It.IsAny <CancellationToken>()
                                           ))
                .ReturnsAsync(customer);

                //Act
                var result = await sut.Handle(query, CancellationToken.None);

                //Assert
                result.Should().BeEquivalentTo(
                    address,
                    opt => opt.Excluding(_ => _.SelectedMemberPath.EndsWith("Id", StringComparison.InvariantCultureIgnoreCase))
                    );

                customerRepoMock.Verify(x => x.GetBySpecAsync(
                                            It.IsAny <GetCustomerAddressesSpecification>(),
                                            It.IsAny <CancellationToken>()
                                            ));
            }
コード例 #26
0
 public static Entities.Address Create(string address1, string address2 = "", string city = "", string state = "", string country = "", string zipCode = "")
 {
     Entities.Address addr = new Entities.Address(address1, address2, city, state, country, zipCode);
     collection.Add(addr);
     return(addr);
 }
コード例 #27
0
        ///	<summary>
        /// Populate Driver
        ///	</summary>
        private void populateDriver()
        {
            if (ViewState["driver"] == null)
            {
                _driver = new Entities.Driver();
            }
            else
            {
                _driver = (Entities.Driver)ViewState["driver"];
            }

            _driver.ResourceType = eResourceType.Driver;
            if (_driver.Individual == null)
            {
                _driver.Individual = new Entities.Individual();
            }

            _driver.Individual.Title      = (eTitle)Enum.Parse(typeof(eTitle), cboTitle.SelectedValue.Replace(" ", ""));
            _driver.Individual.FirstNames = txtFirstNames.Text;
            _driver.Individual.LastName   = txtLastName.Text;
            if (dteDOB.SelectedDate != null)
            {
                _driver.Individual.DOB = dteDOB.SelectedDate.Value;
            }
            else
            {
                _driver.Individual.DOB = DateTime.MinValue;
            }
            _driver.Individual.IndividualType = eIndividualType.Driver;
            _driver.Passcode = txtPasscode.Text;

            if (_driver.Individual.Address == null)
            {
                _driver.Individual.Addresses = new Entities.AddressCollection();
                _driver.Individual.Addresses.Add(new Entities.Address());
            }

            _driver.Individual.Address.AddressLine1 = txtAddressLine1.Text;
            _driver.Individual.Address.AddressLine2 = txtAddressLine2.Text;
            _driver.Individual.Address.AddressLine3 = txtAddressLine3.Text;
            _driver.Individual.Address.PostTown     = txtPostTown.Text;
            _driver.Individual.Address.County       = txtCounty.Text;
            _driver.Individual.Address.PostCode     = txtPostCode.Text;

            if (_driver.Individual.Address.TrafficArea == null)
            {
                _driver.Individual.Address.TrafficArea = new Orchestrator.Entities.TrafficArea();
            }
            if (hidTrafficArea.Value != "")
            {
                _driver.Individual.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value);
            }

            if (_driver.Individual.Contacts == null)
            {
                _driver.Individual.Contacts = new Entities.ContactCollection();
            }

            Entities.Contact contact = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone);
            if (null == contact)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.Telephone;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtTelephone.Text;

            contact = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone);
            if (null == contact)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.MobilePhone;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtMobilePhone.Text;

            contact = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile);

            if (contact == null)
            {
                contact             = new Entities.Contact();
                contact.ContactType = eContactType.PersonalMobile;
                _driver.Individual.Contacts.Add(contact);
            }

            contact.ContactDetail = txtPersonalMobile.Text;

            // Retrieve the organisation and place it in viewstate
            Facade.IOrganisation          facOrganisation             = new Facade.Organisation();
            Entities.Organisation         m_organisation              = facOrganisation.GetForIdentityId(Orchestrator.Globals.Configuration.IdentityId);
            Entities.OrganisationLocation currentOrganisationLocation = null;
            Entities.Point   currentPoint   = null;
            Entities.Address currentAddress = null;
            if (m_organisation != null && m_organisation.Locations.Count > 0)
            {
                currentOrganisationLocation = m_organisation.Locations.GetHeadOffice();
                currentPoint   = currentOrganisationLocation.Point;
                currentAddress = currentPoint.Address;
            }

            if (cboPoint.SelectedValue != "")
            {
                _driver.HomePointId = Convert.ToInt32(cboPoint.SelectedValue);
            }
            else
            {
                _driver.HomePointId = currentPoint.PointId;
            }
            if (Convert.ToInt32(cboVehicle.SelectedValue) > 0)
            {
                _driver.AssignedVehicleId = Convert.ToInt32(cboVehicle.SelectedValue);
            }
            else
            {
                _driver.AssignedVehicleId = 0;
            }

            if (chkDelete.Checked)
            {
                _driver.Individual.IdentityStatus = eIdentityStatus.Deleted;
                _driver.ResourceStatus            = eResourceStatus.Deleted;
            }
            else
            {
                _driver.Individual.IdentityStatus = eIdentityStatus.Active;
                _driver.ResourceStatus            = eResourceStatus.Active;
            }

            if (_driver.Point == null && cboTown.SelectedValue != "")
            {
                _driver.Point = new Entities.Point();
            }

            if (cboDepot.SelectedValue != "")
            {
                _driver.DepotId = Convert.ToInt32(cboDepot.SelectedValue);
            }
            else
            {
                _driver.DepotId = currentOrganisationLocation.OrganisationLocationId;
            }

            if (_driver.Point != null)
            {
                decimal dLatitude = 0;
                decimal.TryParse(txtLatitude.Text, out dLatitude);
                decimal dLongtitude = 0;
                decimal.TryParse(txtLongitude.Text, out dLongtitude);

                _driver.Individual.Address.Latitude  = dLatitude;
                _driver.Individual.Address.Longitude = dLongtitude;
                _driver.Point.PostTown = new Entities.PostTown();
                Facade.IPostTown facPostTown = new Facade.Point();
                _driver.Point.IdentityId  = 0;
                _driver.Point.PostTown    = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboTown.SelectedValue));
                _driver.Point.Address     = _driver.Individual.Address;
                _driver.Point.Latitude    = dLatitude;
                _driver.Point.Longitude   = dLongtitude;
                _driver.Point.Description = _driver.Individual.FirstNames + " " + _driver.Individual.LastName + " - Home";
                // We must try to set the radius of the point so that a new geofence
                // can be generated as we have just changed the point location through the address lookup.
                // not sure that this is neccessary for drivers though
                if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
                {
                    _driver.Point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                }
            }

            if (cboDriverType.SelectedValue != "")
            {
                _driver.DriverType.DriverTypeID = int.Parse(cboDriverType.SelectedValue);
            }
            else
            {
                _driver.DriverType.DriverTypeID = 1;
            }

            _driver.DigitalTachoCardId = txtDigitalTachoCardId.Text;
            _driver.IsAgencyDriver     = chkAgencyDriver.Checked;
            if (dteSD.SelectedDate != null)
            {
                _driver.StartDate = dteSD.SelectedDate.Value;
            }
            else
            {
                _driver.StartDate = null;
            }
            _driver.PayrollNo = txtPayrollNo.Text;

            string selectedCommunicationType = rblDefaultCommunicationType.SelectedValue;

            if (selectedCommunicationType == "None")
            {
                _driver.DefaultCommunicationTypeID = 0;
            }
            else
            {
                _driver.DefaultCommunicationTypeID = (int)Enum.Parse(typeof(eDriverCommunicationType), rblDefaultCommunicationType.SelectedValue);
            }

            _driver.OrgUnitIDs = trvResourceGrouping.CheckedNodes.Select(x => Int32.Parse(x.Attributes["OrgUnitID"])).ToList();

            // if the telematics option is visible use the selected solution (validation enforces a non-null selection)
            if (telematicsOption.Visible)
            {
                _driver.TelematicsSolution = (eTelematicsSolution?)Enum.Parse(typeof(eTelematicsSolution), cboTelematicsSolution.SelectedValue);
            }
            else
            {
                // if telematics option is not visible and we're creating, use the default
                if (!_isUpdate && ViewState["defaultTelematicsSolution"] != null)
                {
                    _driver.TelematicsSolution = (eTelematicsSolution)ViewState["defaultTelematicsSolution"];
                }
                //otherwise leave the telematics solution as it is
            }

            if (!string.IsNullOrEmpty(cboDriverPlanner.SelectedValue))
            {
                _driver.PlannerIdentityID = Convert.ToInt32(cboDriverPlanner.SelectedValue);
            }
            else
            {
                _driver.PlannerIdentityID = null;   //PROT-6452 - un-allocating a driver from its planner
            }

            if (chkAgencyDriver.Checked)
            {
                if (cboAgency.SelectedIndex == -1)
                {
                    var agency = new Agency()
                    {
                        Name = cboAgency.Text
                    };

                    using (var uow = DIContainer.CreateUnitOfWork())
                    {
                        var agenciesRepo = DIContainer.CreateRepository <IAgencyRepository>(uow);
                        agenciesRepo.Add(agency);
                        uow.SaveChanges();
                    }
                    _driver.AgencyId = agency.AgencyId;
                }
                else
                {
                    _driver.AgencyId = int.Parse(cboAgency.SelectedItem.Value);
                }
            }
            else
            {
                _driver.AgencyId = null;
            }


            ViewState["driver"] = _driver;
        }
コード例 #28
0
 public Task <object> Handle(AddNewCustomerCommand command, CancellationToken cancellationToken)
 {
     if (!command.IsValid())
     {
         NotifyValidationErrors(command);
     }
     else
     {
         AddressModel addressModel = _AddressRepository.GetByLatLng(command.Lat, command.Lng);
         if (addressModel == null)
         {
             Entities.Address address = new Entities.Address(
                 null,
                 new City(command.City),
                 new Country(command.Country),
                 new District(command.District),
                 new Lat(command.Lat),
                 new Lng(command.Lng),
                 new Street(command.Street),
                 new StreetNumber(command.StreetNumber)
                 );
             addressModel = _AddressRepository.Add(address);
         }
         Entities.Customer u = new Entities.Customer(
             null,
             new Name(command.Name),
             new Note(command.Note),
             new CartCode(command.CartCode),
             new PhoneNumber(command.PhoneNumber),
             new Email(command.Email),
             new Code(command.Code),
             new Status(command.Status),
             new Entities.Address(
                 new Identity((uint)addressModel.ID),
                 new City(command.City),
                 new Country(command.Country),
                 new District(command.District),
                 new Lat(command.Lat),
                 new Lng(command.Lng),
                 new Street(command.Street),
                 new StreetNumber(command.StreetNumber)
                 )
             );
         CustomerModel model = _CustomerRepository.Add(u);
         if (model != null)
         {
             AccountModel account = new AccountModel()
             {
                 DisplayName = model.Name,
                 Name        = model.Name,
                 Role        = 2,
                 Status      = 0,
                 UserName    = model.Code,
                 UserTypeID  = model.ID,
                 UpdatedAt   = DateTime.Now,
                 Password    = Guid.NewGuid().ToString("d").Substring(0, 8)
             };
             _AccountRepository.Add(account);
             string message = "Bạn vừa đăng ký thành công trên hệ thống Anvita. Tài khoản của bạn là: " +
                              account.UserName + ", password: "******". Vui lòng truy cập trang đặt hàng để thay đổi mật khẩu!";
             SendSMS.SendSMSCommon.SendSMS(message, "+84" + model.PhoneNumber.Substring(1));
             return(Task.FromResult(model as object));
         }
         _bus.RaiseEvent(new DomainNotification("Customer", "Server error", NotificationCode.Error));
     }
     return(Task.FromResult(null as object));
 }
コード例 #29
0
 public void Add(Entities.Address address)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
		private void OnAddressBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentAddress = uxAddressBindingSource.Current as Entities.Address;
			
			if (_currentAddress != null)
			{
				_currentAddress.Validate();
			}
			//_Address.Validate();
			OnCurrentEntityChanged();
		}
コード例 #31
0
ファイル: AddPoint.ascx.cs プロジェクト: norio-soft/proteo
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                #region Create the new point

                Entities.Point newPoint = new Entities.Point();

                Facade.IPostTown  facPostTown = new Facade.Point();
                Entities.PostTown town        = facPostTown.GetPostTownForTownId((int)Session[wizard.C_TOWN_ID]);

                // Set the point owner and description
                newPoint.IdentityId  = (int)Session[wizard.C_POINT_FOR];
                newPoint.Description = Session[wizard.C_POINT_NAME].ToString();

                // Get the point type
                switch ((ePointType)Session[wizard.C_POINT_TYPE])
                {
                case ePointType.Collect:
                    newPoint.Collect = true;
                    break;

                case ePointType.Deliver:
                    newPoint.Deliver = true;
                    break;

                case ePointType.Any:
                    newPoint.Collect = true;
                    newPoint.Deliver = true;
                    break;
                }

                // set the address
                Entities.Address address = new Entities.Address();
                address.AddressLine1 = txtAddressLine1.Text;
                address.AddressLine2 = txtAddressLine2.Text;
                address.AddressLine3 = txtAddressLine3.Text;
                address.AddressType  = eAddressType.Point;
                address.County       = txtCounty.Text;
                address.IdentityId   = newPoint.IdentityId;
                address.Latitude     = Decimal.Parse(txtLatitude.Text);
                address.Longitude    = Decimal.Parse(txtLongitude.Text);
                address.PostCode     = txtPostCode.Text;
                address.PostTown     = txtPostTown.Text;
                if (address.TrafficArea == null)
                {
                    address.TrafficArea = new Orchestrator.Entities.TrafficArea();
                }

                address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value);
                newPoint.Address   = address;
                newPoint.Longitude = address.Longitude;
                newPoint.Latitude  = address.Latitude;

                Facade.IOrganisation facOrganisation            = new Facade.Organisation();
                Orchestrator.Entities.Organisation organisation = facOrganisation.GetForIdentityId(newPoint.IdentityId);

                // set the radius if the address was changed by addressLookup
                // if the org has a default, use it, if not, use the system default.
                if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value))
                {
                    if (organisation.Defaults[0].DefaultGeofenceRadius == null)
                    {
                        newPoint.Radius = Globals.Configuration.GPSDefaultGeofenceRadius;
                    }
                    else
                    {
                        newPoint.Radius = organisation.Defaults[0].DefaultGeofenceRadius;
                    }
                }

                newPoint.PostTown   = town;
                newPoint.PointNotes = txtPointNotes.Text;

                string userId = ((Entities.CustomPrincipal)Page.User).UserName;

                // Create the new point
                Facade.IPoint         facPoint = new Facade.Point();
                Entities.FacadeResult result   = facPoint.Create(newPoint, userId);

                int pointId = facPoint.Create(newPoint, userId).ObjectId;

                #endregion

                if (pointId == 0)
                {
                    // This customer already has a point with this name
                    // Try to locate the point
                    Entities.PointCollection points = facPoint.GetClientPointsForName(newPoint.IdentityId, newPoint.Description);
                    if (points.Count == 1)
                    {
                        // The point id has been found!
                        pointId = points[0].PointId;
                    }
                    else
                    {
                        // Clear the session variables used to help add the new point
                        Session[wizard.C_POINT_TYPE] = null;
                        Session[wizard.C_POINT_FOR]  = null;
                        Session[wizard.C_POINT_NAME] = null;
                        Session[wizard.C_TOWN_ID]    = null;

                        GoToStep("P");
                    }
                }

                if (pointId > 0)
                {
                    // Reload the point to ensure we have all the ancillary entities
                    Entities.Point createdPoint = facPoint.GetPointForPointId(pointId);

                    if (m_isUpdate)
                    {
                        // Add the collect drop point information
                        if (m_instruction == null)
                        {
                            m_instruction = new Entities.Instruction();

                            m_instruction.JobId = m_jobId;
                            switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                            {
                            case ePointType.Collect:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                break;

                            case ePointType.Deliver:
                                m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                break;
                            }
                        }

                        m_instruction.Point         = createdPoint;
                        m_instruction.PointID       = createdPoint.PointId;
                        m_instruction.InstructionID = m_instruction.InstructionID;

                        if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                        {
                            m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                        }

                        // Cause the first docket to be displayed.
                        if (m_instruction.CollectDrops.Count > 0)
                        {
                            Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                            Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                        }

                        Session[wizard.C_INSTRUCTION] = m_instruction;
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                m_instruction.Point   = createdPoint;
                                m_instruction.PointID = createdPoint.PointId;
                            }

                            // Cause the first docket to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            // Add the collect drop point information
                            if (m_instruction == null)
                            {
                                m_instruction = new Entities.Instruction();

                                m_instruction.JobId = m_jobId;
                                switch ((ePointType)(int)Session[wizard.C_POINT_TYPE])
                                {
                                case ePointType.Collect:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                                    break;

                                case ePointType.Deliver:
                                    m_instruction.InstructionTypeId = (int)eInstructionType.Drop;
                                    break;
                                }
                            }

                            m_instruction.Point         = createdPoint;
                            m_instruction.PointID       = createdPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                            {
                                m_instruction.ClientsCustomerIdentityID = createdPoint.IdentityId;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }