Esempio n. 1
0
 /// <summary>
 /// Map a Model Car from a Entity Car
 /// </summary>
 /// <param name="car">A Car Entity</param>
 /// <returns>A Car Model</returns>
 public Lib.Models.Car MapCar(Entities.Car car)
 {
     return(new Lib.Models.Car
     {
         Id = car.Id,
         LicensePlate = car.LicensePlate,
         Make = car.Make,
         Model = car.Model,
         Color = car.Color,
         Year = car.Year,
         State = car.State
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Map a Entity Tenant from a Model Tenant
        /// </summary>
        /// <param name="tenant">A Tenant Model who may have a nested Car Model and/or a Batch Model</param>
        /// <returns>A Tenant Entity who may have a nested Car Model and/or a Batch Model</returns>
        public Entities.Tenant MapTenant(Lib.Models.Tenant tenant)
        {
            Entities.Car newCar;
            int?         newCarId = 0;

            if (tenant.Car != null)
            {
                newCar = new Entities.Car
                {
                    Id           = 0,
                    LicensePlate = tenant.Car.LicensePlate,
                    Make         = tenant.Car.Make,
                    Model        = tenant.Car.Model,
                    Color        = tenant.Car.Color,
                    Year         = tenant.Car.Year,
                    State        = tenant.Car.State
                                   //maybe add tenant
                };
            }
            else
            {
                newCar   = null;
                newCarId = null;
            }


            return(new Entities.Tenant
            {
                Id = tenant.Id,
                Email = tenant.Email,
                Gender = tenant.Gender,
                FirstName = tenant.FirstName,
                LastName = tenant.LastName,
                AddressId = tenant.AddressId,
                RoomId = tenant.RoomId,
                CarId = newCarId,
                BatchId = tenant.BatchId,
                TrainingCenter = tenant.TrainingCenter,
                Car = newCar
            });
        }