public static void UpdateEntity(this Data.Vehicle entity, RegiX.Client.ResponseModels.Vehicle model) { if (model == null || entity == null) { return; } entity.RegistrationNumber = model.VehicleRegistrationNumber; entity.FirstRegistrationDate = model.FirstRegistrationDateSpecified ? DateTime.SpecifyKind(model.FirstRegistrationDate, DateTimeKind.Utc) : default(DateTime?); entity.Vin = model.VINNumber; entity.EngineNumber = model.EngineNumber; entity.VehicleType = model.MotorVehicleType; entity.Model = model.MotorVehicleModel; entity.TradeDescription = model.TradeDescription; entity.Color = model.Color; entity.Category = model.Category; entity.VehicleOwner = new List <VehicleOwner>(); entity.VehicleOwner.Add(new VehicleOwner { BulgarianCitizenPin = model.OwnerPersonData?.EGN, BulgarianCitizenFirstName = model.OwnerPersonData?.FirstName, BulgarianCitizenMiddleName = model.OwnerPersonData?.Surname, BulgarianCitizenLastName = model.OwnerPersonData?.FamilyName, ForeignCitizenPin = model.OwnerForeignerPersonData?.EGN, ForeignCitizenPn = model.OwnerForeignerPersonData?.LNCh, ForeignCitizenNamesCyrillic = model.OwnerForeignerPersonData?.Names, ForeignCitizenNamesLatin = model.OwnerForeignerPersonData?.NamesLatin, CompanyId = model.OwnerEntityData?.Identifier, CompanyName = model.OwnerEntityData?.Name, CompanyNameLatin = model.OwnerEntityData?.NameLatin, }); return; }
public static VehicleViewModel ToViewModel(this RegiX.Client.ResponseModels.Vehicle model) { if (model == null) { return(null); } VehicleViewModel viewModel = new VehicleViewModel { Id = -1, RegistrationNumber = model.VehicleRegistrationNumber, FirstRegistrationDate = model.FirstRegistrationDateSpecified ? DateTime.SpecifyKind(model.FirstRegistrationDate, DateTimeKind.Utc) : default(DateTime?), Vin = model.VINNumber, EngineNumber = model.EngineNumber, VehicleType = model.MotorVehicleType, Model = model.MotorVehicleModel, TradeDescription = model.TradeDescription, Color = model.Color, Category = model.Category, }; viewModel.Owners = CreateVehicleOwnerViewNodels(model); return(viewModel); }
private static List <VehicleOwnerViewModel> CreateVehicleOwnerViewNodels(RegiX.Client.ResponseModels.Vehicle model) { VehicleOwnerViewModel owner = new VehicleOwnerViewModel { BulgarianCitizenPin = model.OwnerPersonData?.EGN, BulgarianCitizenFirstName = model.OwnerPersonData?.FirstName, BulgarianCitizenMiddleName = model.OwnerPersonData?.Surname, BulgarianCitizenLastName = model.OwnerPersonData?.FamilyName, ForeignCitizenPin = model.OwnerForeignerPersonData?.EGN, ForeignCitizenPn = model.OwnerForeignerPersonData?.LNCh, ForeignCitizenNamesCyrillic = model.OwnerForeignerPersonData?.Names, ForeignCitizenNamesLatin = model.OwnerForeignerPersonData?.NamesLatin, CompanyId = model.OwnerEntityData?.Identifier, CompanyName = model.OwnerEntityData?.Name, CompanyNameLatin = model.OwnerEntityData?.NameLatin, }; List <VehicleOwnerViewModel> list = new List <VehicleOwnerViewModel>(); list.Add(owner); return(list); }