Example #1
0
        public Data.Entity.Vehicle Save(Data.Entity.Vehicle entity)
        {
            VehicleStorage.VehicleList.Add(entity);
            VehicleStorage.VehicleDictionary.Add(entity.Id, entity);

            return(entity);
        }
        public VehicleResult Find(long id)
        {
            Data.Entity.Vehicle entity = VehicleDao.Find(id);
            VehicleResult       result = VehicleResultConverter.Convert(entity);

            return(result);
        }
        public VehicleResult Create(VehicleParam param)
        {
            Data.Entity.Vehicle entity = VehicleParamConverter.Convert(param, null);
            VehicleDao.Save(entity);

            return(VehicleResultConverter.Convert(entity));
        }
Example #4
0
        public Data.Entity.Vehicle Convert(VehicleParam param, Data.Entity.Vehicle oldentity)
        {
            Data.Entity.Vehicle entity = null;

            if (oldentity != null)
            {
                entity = oldentity;
            }
            else
            {
                entity = new Data.Entity.Vehicle
                {
                    Code        = param.Code,
                    Id          = param.Id,
                    Description = param.Description,
                    Name        = param.Name
                };
            }

            entity.Owner            = CustomerDao.Find(param.OwnerId);
            entity.Mileage          = param.Mileage;
            entity.DateOfProduction = param.DateOfProduction;
            entity.VehicleStatus    = VehicleStatusDao.Find(param.VehicleStatusId);

            return(entity);
        }
Example #5
0
        static VehicleStorage()
        {
            Data.Entity.Vehicle Vehicle1 = new Data.Entity.Vehicle
            {
            };

            Data.Entity.Vehicle Vehicle2 = new Data.Entity.Vehicle
            {
            };

            Data.Entity.Vehicle Vehicle3 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle4 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle5 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle6 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle7 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle8 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle9 = new Data.Entity.Vehicle
            {
            };
            Data.Entity.Vehicle Vehicle10 = new Data.Entity.Vehicle
            {
            };

            VehicleList.Add(Vehicle1);
            VehicleList.Add(Vehicle2);
            VehicleList.Add(Vehicle3);
            VehicleList.Add(Vehicle4);
            VehicleList.Add(Vehicle5);
            VehicleList.Add(Vehicle6);
            VehicleList.Add(Vehicle7);
            VehicleList.Add(Vehicle8);
            VehicleList.Add(Vehicle9);
            VehicleList.Add(Vehicle10);

            VehicleDictionary.Add(Vehicle1.Id, Vehicle1);
            VehicleDictionary.Add(Vehicle2.Id, Vehicle2);
            VehicleDictionary.Add(Vehicle3.Id, Vehicle3);
            VehicleDictionary.Add(Vehicle4.Id, Vehicle4);
            VehicleDictionary.Add(Vehicle5.Id, Vehicle5);
            VehicleDictionary.Add(Vehicle6.Id, Vehicle6);
            VehicleDictionary.Add(Vehicle7.Id, Vehicle7);
            VehicleDictionary.Add(Vehicle8.Id, Vehicle8);
            VehicleDictionary.Add(Vehicle9.Id, Vehicle9);
            VehicleDictionary.Add(Vehicle10.Id, Vehicle10);
        }
        public void Update(List <VehicleParam> param)
        {
            List <Data.Entity.Vehicle> entity = new List <Data.Entity.Vehicle>();

            foreach (var item in param)
            {
                Data.Entity.Vehicle oldEntity = VehicleDao.Find(item.Id);
                Data.Entity.Vehicle newEntity = VehicleParamConverter.Convert(item, null);
                VehicleDao.Update(newEntity);
            }
        }
Example #7
0
        public VehicleResult Convert(Data.Entity.Vehicle param)
        {
            VehicleResult result = new VehicleResult()
            {
                Code        = param.Code,
                Id          = param.Id,
                Description = param.Description,
                Name        = param.Name,

                VehicleStatusId   = param.VehicleStatus.Id,
                VehicleStatusName = param.VehicleStatus.Name,
                DateOfProduction  = param.DateOfProduction,
                Mileage           = param.Mileage,
                OwnerId           = param.Owner.Id,
                OwnerName         = param.Owner.Name
            };

            return(result);
        }
Example #8
0
 public Data.Entity.Vehicle Update(Data.Entity.Vehicle entity)
 {
     Delete(entity.Id);
     Save(entity);
     return(entity);
 }
Example #9
0
 public void Delete(Data.Entity.Vehicle entity)
 {
     VehicleStorage.VehicleList.Remove(entity);
     VehicleStorage.VehicleDictionary.Remove(entity.Id);
 }
Example #10
0
 public void Delete(long id)
 {
     Data.Entity.Vehicle entity = Find(id);
     Delete(entity);
 }
 public void Update(long id, VehicleParam param)
 {
     Data.Entity.Vehicle oldEntity = VehicleDao.Find(id);
     Data.Entity.Vehicle newEntity = VehicleParamConverter.Convert(param, null);
     VehicleDao.Update(newEntity);
 }