コード例 #1
0
        public async Task GetAddresses()
        {
            var request = "Москв";

            var externalResult     = new AddressEM();
            var externalListResult = new List <AddressEM> {
                externalResult
            };

            Suite.AddressAPIMock
            .Setup(m => m.GetAddress(request))
            .ReturnsAsync(externalListResult);

            var domainResult     = new AddressDM();
            var domainListResult = new List <AddressDM> {
                domainResult
            };

            Suite.MappingServiceMock
            .Setup(m => m.Map <ICollection <AddressEM>, ICollection <AddressDM> >(externalListResult))
            .Returns(domainListResult);

            var addresses = await Suite.AddressesRepository.GetAddresses(request, RequestPriority.UserInitiated);

            Suite.AddressAPIMock
            .Verify(m => m.GetAddress(request), Times.Once);

            Suite.MappingServiceMock
            .Verify(
                m => m.Map <ICollection <AddressEM>, ICollection <AddressDM> >(
                    It.Is <List <AddressEM> >(l => l.Equals(externalListResult))),
                Times.Once);

            Assert.Equal(domainListResult, addresses);
        }
コード例 #2
0
ファイル: AddressDAL.cs プロジェクト: 89mich7/ORA
        /// <summary>
        /// Basic CRUD methods for address information. AddressDM is the model being used here.
        /// </summary>

        #region ADDRESS DAL METHODS
        public static void CreateAddress(AddressDM address, long empID)
        {
            try
            {
                //Creating a way of adding new user information to my database
                using (SqlCommand cmd = new SqlCommand("CREATE_ADDRESS", SqlConnect.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Employee_ID", empID);
                    cmd.Parameters.AddWithValue("@Address", address.Address);
                    cmd.Parameters.AddWithValue("@City", address.City);
                    cmd.Parameters.AddWithValue("@State", address.State);
                    cmd.Parameters.AddWithValue("@Zip_Code", address.Zip_Code);
                    cmd.Parameters.AddWithValue("@Country", address.Country);
                    cmd.Parameters.AddWithValue("@Phone", address.Phone);
                    cmd.Parameters.AddWithValue("@Email", address.Email);
                    SqlConnect.Connection.Open();
                    cmd.ExecuteNonQuery();
                    SqlConnect.Connection.Close();
                }
            }
            catch (Exception e)
            {
                SqlConnect.Connection.Close();
                throw e;
            }
        }
コード例 #3
0
ファイル: AddressDAL.cs プロジェクト: 89mich7/ORA
 public static void UpdateAddress(AddressDM address)
 {
     try
     {
         using (SqlCommand cmd = new SqlCommand("UPDATE_ADDRESS", SqlConnect.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Address_ID", address.Address_ID);
             cmd.Parameters.AddWithValue("@Address", address.Address);
             cmd.Parameters.AddWithValue("@FirstName", address.City);
             cmd.Parameters.AddWithValue("@LastName", address.State);
             cmd.Parameters.AddWithValue("@DoB", address.Zip_Code);
             cmd.Parameters.AddWithValue("@PhoneNumber", address.Country);
             cmd.Parameters.AddWithValue("@UserName", address.Phone);
             cmd.Parameters.AddWithValue("@Password", address.Email);
             SqlConnect.Connection.Open();
             cmd.ExecuteNonQuery();
             SqlConnect.Connection.Close();
         }
     }
     catch (Exception e)
     {
         SqlConnect.Connection.Close();
         throw (e);
     }
 }
コード例 #4
0
ファイル: AddressDAL.cs プロジェクト: 89mich7/ORA
        public static List <AddressDM> ReadAllAddress()
        {
            List <AddressDM> addressList = new List <AddressDM>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("READ_ALL_ADDRESS", SqlConnect.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlConnect.Connection.Open();
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            return(addressList);
                        }
                        while (reader.Read())
                        {
                            var address = new AddressDM
                            {
                                Address_ID = (Int64)reader["Address_ID"],
                                Address    = (string)reader["Address"],
                                City       = (string)reader["City"],
                                State      = (string)reader["State"],
                                Zip_Code   = (int)reader["Zip_Code"],
                                Country    = (string)reader["Country"],
                                Phone      = (string)reader["Phone"],
                                Email      = (string)reader["Email"]
                            };
                            addressList.Add(address);
                        }
                    }
                    SqlConnect.Connection.Close();
                }
                return(addressList);
            }
            catch (Exception ex)
            {
                SqlConnect.Connection.Close();
                throw ex;
            }
        }
コード例 #5
0
        private AddressVM BuildAddressVM(AddressDM dataModel)
        {
            if (dataModel == null)
            {
                return(null);
            }

            return(new AddressVM
            {
                Id = dataModel.Id,
                RestaurantId = dataModel.RestaurantId,
                StreetName = dataModel.StreetName,
                CityName = dataModel.CityName,
                StateName = dataModel.StateName,
                StateAbbr = dataModel.StateAbbr,
                Zip = dataModel.Zip,
                Country = dataModel.Country,
                CountryAbbr = dataModel.CountryAbbr
            });
        }
コード例 #6
0
ファイル: AddressDAL.cs プロジェクト: 89mich7/ORA
 public static void DeleteAddress(AddressDM address)
 {
     try
     {
         using (SqlCommand cmd = new SqlCommand("DELETE_ADDRESS", SqlConnect.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Address_ID", address.Address_ID);
             SqlConnect.Connection.Open();
             cmd.ExecuteNonQuery();
             SqlConnect.Connection.Close();
         }
     }
     catch (Exception ex)
     {
         SqlConnect.Connection.Close();
         //Write to error log
         throw ex;
     }
 }
コード例 #7
0
        private static Uri GetVoterPassUri(AddressDM permanentAddress, PersonalDataDM personalData, Office office, VotePerson votePerson, AddressDM contactAddress)
        {
            string baseUrl        = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority;
            string controllerPath = "/api/file";

            var contactAddressString = contactAddress == null ? string.Empty : contactAddress.ToAddressString();

            string query = $"?name={Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(personalData.Name.ToLower())}";

            query += $"&birthDate={((DateTime)personalData.BirthDateConverted).ToShortDateString()}";
            query += $"&phone={personalData.Phone}";
            query += $"&permanentAddress={permanentAddress.ToAddressString()}";
            query += $"&contactAddress={contactAddressString}";
            query += $"&officeName={office?.name ?? string.Empty}";
            query += $"&officeAddress={office?.address ?? string.Empty}";
            query += $"&officePostalCode={office?.zip ?? string.Empty}";
            query += $"&officeCity={office?.city ?? string.Empty}";
            query += $"&voterPersonType={votePerson.Type}";

            return(new Uri(baseUrl + controllerPath + query));
        }
コード例 #8
0
ファイル: AddressDAL.cs プロジェクト: 89mich7/ORA
 public static AddressDM ReadAddressByID(string addressId)
 {
     try
     {
         AddressDM address = new AddressDM();
         using (SqlCommand cmd = new SqlCommand("READ_ADDRESS_BY_ID", SqlConnect.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             SqlConnect.Connection.Open();
             cmd.Parameters.AddWithValue("@Address_ID", addressId);
             using (var reader = cmd.ExecuteReader())
             {
                 if (!reader.HasRows)
                 {
                     return(address);
                 }
                 while (reader.Read())
                 {
                     address.Address_ID = (Int64)reader["Address_ID"];
                     address.Address    = (string)reader["Address"];
                     address.City       = (string)reader["City"];
                     address.State      = (string)reader["State"];
                     address.Zip_Code   = (int)reader["Zip_Code"];
                     address.Country    = (string)reader["Country"];
                     address.Phone      = (string)reader["Phone"];
                     address.Email      = (string)reader["Email"];
                 }
             }
             SqlConnect.Connection.Close();
         }
         return(address);
     }
     catch (Exception ex)
     {
         SqlConnect.Connection.Close();
         throw ex;
     }
 }
コード例 #9
0
ファイル: EmployeeDAL.cs プロジェクト: 89mich7/ORA
        public List <EmployeeDM> ReadEmployees()
        {
            List <EmployeeDM> employeeList = new List <EmployeeDM>();

            try
            {
                SqlConnect.Connection.Open();
                using (SqlCommand cmd = new SqlCommand("READ_EMPLOYEES", SqlConnect.Connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            return(employeeList);
                        }
                        while (reader.Read())
                        {
                            //Creating objects of the modals inside the loop so that
                            //the object can be used for new information every iteration of the loop.
                            #region Modal Objects
                            EmployeeDM     employee     = new EmployeeDM();
                            AddressDM      address      = new AddressDM();
                            EmployeeTimeDM EmployeeTime = new EmployeeTimeDM();
                            PositionsDM    position     = new PositionsDM();
                            StatusDM       Status       = new StatusDM();
                            #endregion

                            #region Pulling Employee Table Information

                            employee.EmployeeId        = (Int64)reader["Employee_ID"];
                            employee.EmployeeNumber    = (string)reader["Employee_Number"];
                            employee.EmployeeName      = (string)reader["Employee_Name"];
                            employee.EmployeeFirstName = (string)reader["Employee_FirstName"];
                            employee.EmployeeMiddle    = (string)reader["Employee_MiddleName"];
                            employee.EmployeeLastName  = (string)reader["Employee_LastName"];
                            employee.Age       = (int)reader["Age"];
                            employee.BirthDate = (DateTime)reader["Birth_Date"];
                            if (reader["Team_ID"] != DBNull.Value)
                            {
                                employee.TeamID = (Int64)reader["Team_ID"];
                            }
                            if (reader["Role_ID"] != DBNull.Value)
                            {
                                employee.RoleID = (Int64)reader["Role_ID"];
                            }
                            if (reader["Assignment_ID"] != DBNull.Value)
                            {
                                employee.AssignmentID = (Int64)reader["Assignment_ID"];
                            }

                            #endregion

                            //#region Pulling Address Table Information
                            //address.Address = (string)reader["Address"];
                            //address.City = (string)reader["City"];
                            //address.State = (string)reader["State"];
                            //address.Country = (string)reader["Country"];
                            //address.Zip_Code = (int)reader["Zip_Code"];
                            //address.Phone = (string)reader["Phone"];
                            //address.Email = (string)reader["Email"];
                            //#endregion

                            //#region Pulls Employee Time Table Information
                            //EmployeeTime.Other_Total = (decimal)reader["Other_Total"];
                            //EmployeeTime.Other_Available = (decimal)reader["Other_Available"];
                            //EmployeeTime.Other_Used = (decimal)reader["Other_Used"];
                            //EmployeeTime.Payed_Total = (decimal)reader["Payed_Total"];
                            //EmployeeTime.Payed_Used = (decimal)reader["Payed_Total"];
                            //#endregion

                            //#region Pulls Employee Work Status Information

                            //Status.EmployeeStatus = (string)reader["Employee_Status"];
                            //Status.HireDate = (DateTime)reader["Hire_Date"];
                            //Status.PayType = (string)reader["Pay_Type"];
                            //Status.ServiceLength = (string)reader["Service_Length"];
                            //Status.EmploymentType = (string)reader["Employment_Type"];
                            //Status.OfficeLocation = (string)reader["Office_Location"];
                            //if (reader["Termination_Date"] != DBNull.Value)
                            //    Status.TerminationDate = (DateTime)reader["Termination_Date"];
                            //#endregion

                            ////Adding the object properties to the employment object to be used together for the view modal
                            //employee.address = address; employee.EmployeeTime = EmployeeTime; employee.Status = Status;

                            employeeList.Add(employee);
                        }
                    }
                    cmd.Connection.Close();
                }
                return(employeeList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                SqlConnect.Connection.Close();
            }
        }