Пример #1
0
 public LocationVO(LocationDO location)
 {
     XPosition = location.LocationX;
     YPosition = location.LocationY;
     Name      = location.Title;
     ID        = location.ID;
 }
Пример #2
0
        public static ILocationInfoDO MapPOtoDO(LocationPO iFrom)
        {
            ILocationInfoDO newlocation = new LocationDO();

            newlocation.LocationID   = iFrom.LocationID;
            newlocation.LocationName = iFrom.LocationName;
            newlocation.Address      = iFrom.Address;
            newlocation.Phone        = iFrom.Phone;
            newlocation.MaxCapacity  = iFrom.MaxCapacity;

            return(newlocation);
        }
        public List <ILocationInfoDO> ViewAllLocations()
        {
            List <ILocationInfoDO> viewList = new List <ILocationInfoDO>();

            try
            {
                //create connection
                using (SqlConnection connectionToSQL = new SqlConnection(connectionString))
                    //create a command
                    using (SqlCommand command = new SqlCommand("VIEW_ALL_LOCATIONS", connectionToSQL))
                    {
                        try
                        {
                            connectionToSQL.Open();
                            //use reader
                            SqlDataReader reader = command.ExecuteReader();
                            while (reader.Read())
                            {
                                ILocationInfoDO location = new LocationDO();

                                location.LocationID   = reader.GetInt64(0);
                                location.LocationName = reader.GetString(1);
                                location.Address      = reader.GetString(2);
                                location.Phone        = reader.GetString(3);
                                location.MaxCapacity  = reader.GetInt64(4);

                                viewList.Add(location);
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLogging.LogError(e);
                            throw e;
                        }
                        finally
                        {
                            connectionToSQL.Close();
                            connectionToSQL.Dispose();
                        }
                    }
            }
            catch (Exception e)
            {
                ErrorLogging.LogError(e);
                throw e;
            }
            finally
            {
            }
            return(viewList);
        }
        public ILocationInfoDO ViewLocationByID(long LocationID)
        {
            ILocationInfoDO viewlocation = new LocationDO();

            try
            {
                using (SqlConnection connectionToSQL = new SqlConnection(connectionString))
                    using (SqlCommand command = new SqlCommand("VIEW_LOCATION_BY_ID", connectionToSQL))
                    {
                        try
                        {
                            command.CommandType    = CommandType.StoredProcedure;
                            command.CommandTimeout = 35;
                            command.Parameters.AddWithValue("@LocationID", LocationID);
                            connectionToSQL.Open();

                            SqlDataReader reader = command.ExecuteReader();
                            while (reader.Read())
                            {
                                viewlocation.LocationID   = reader.GetInt64(0);
                                viewlocation.LocationName = reader.GetString(1);
                                viewlocation.Address      = reader.GetString(2);
                                viewlocation.Phone        = reader.GetString(3);
                                viewlocation.MaxCapacity  = reader.GetInt64(4);
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLogging.LogError(e);
                            throw e;
                        }
                        finally
                        {
                        }
                    }
            }
            catch (Exception e)
            {
                ErrorLogging.LogError(e);
                throw e;
            }
            finally
            {
                //nothing
            }
            return(viewlocation);
        }
Пример #5
0
        public void MapDOtoPO()
        {
            //arange
            ILocationInfoDO mock = new LocationDO();

            mock.LocationID   = 99;
            mock.LocationName = "Home";
            mock.Address      = "123 Main";
            mock.Phone        = "999-999-9999";
            mock.MaxCapacity  = 50000;

            //act
            var result = LocationMap.MapDOtoPO(mock);

            //assert
            Assert.AreEqual(99, result.LocationID);
            Assert.AreEqual("Home", result.LocationName);
            Assert.AreEqual("123 Main", result.Address);
            Assert.AreEqual("999-999-9999", result.Phone);
            Assert.AreEqual(50000, result.MaxCapacity);

            //assert for full method
            // Assert.AreEqual(result, mock);
        }