示例#1
0
        public static Driver Map(Data.Driver driver)
        {
            if (driver == null)
            {
                return(null);
            }
            Driver d = new Driver(Map(driver.User));

            d.DriverId     = driver.Id;
            d.Seats        = driver.Seats.Value;
            d.MeetLoc      = driver.MeetLoc;
            d.DriverRating = driver.Rating.Value;
            return(d);
        }
示例#2
0
 public static Data.Driver Map(Driver driver)
 {
     if (driver == null)
     {
         return(null);
     }
     Data.Driver d = new Data.Driver();
     if (driver.Id > -1)
     {
         d.Id = driver.Id;
     }
     d.Seats   = driver.Seats;
     d.MeetLoc = driver.MeetLoc;
     d.UserId  = driver.Id;
     d.Rating  = driver.DriverRating;
     return(d);
 }
示例#3
0
        public void TestDataDriver()
        {
            Data.Driver driver = new Data.Driver()
            {
                Id      = 0,
                MeetLoc = "Garage",
                Seats   = 4,
                UserId  = 1,
                Rating  = 0,
                User    = new Data.Usr
                {
                    UserName     = "******",
                    EmailAddress = "*****@*****.**",
                    Pass         = "******",
                    Company      = "Revature"
                }
            };
            var expected = Mapper.Map(driver);

            Assert.NotNull(expected);
        }
        /// <summary>
        /// Adds driver settings to the database for an existing user. does not check user exists
        /// </summary>
        /// <param name="driverId"></param>
        /// <param name="userId"></param>
        /// <param name="seats"></param>
        /// <param name="meetingLoc"></param>
        /// <returns></returns>
        public async Task AddDriver(int userId, int seats, string meetingLoc)
        {
            var driver = new Data.Driver
            {
                UserId  = userId,
                Seats   = seats,
                MeetLoc = meetingLoc,
                Rating  = 0
            };

            try
            {
                bbBContext.Add(driver);
                await bbBContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                logger.Info(ex);
                throw;
            }
        }