public GroupListViewModel(GroupItem t = null) { if (t == null) { return; } Id = t.Id; Code = t.Code; Name = t.Name; ChiefName = t.ChiefName; ChiefTel = t.ChiefTel; ChiefTitle = t.ChiefTitle; Address = t.Address; License = t.License; Type = t.Type; VehicleCount = t.Vehicles.Count; InvalidVehicleCount = t.Vehicles.Count(v => !v.IsValid()); DriverCount = t.Drivers.Count; InvalidDriverCount = t.Drivers.Count(d => !d.IsValid()); IsValid = t.IsValid(); TownName = t.Town?.Name; PoliceOffice = t.PoliceOffice; Policeman = t.Policeman; }
public GroupViewModel(GroupItem group) { OriginalModel = group; Id = group.Id; Code = group.Code; Name = group.Name; Address = group.Address; RegisterAddress = group.RegisterAddress; License = group.License; ChiefName = group.ChiefName; ChiefTitle = group.ChiefTitle; ChiefTel = group.ChiefTel; TownId = group.TownId; TownName = group.Town?.Name; Type = group.Type; Comment = group.Comment; Policeman = group.Policeman; PoliceOffice = group.PoliceOffice; ApplicationFileId = group.ApplicationFileId; RuleFileId = group.RuleFileId; DriverGuranteeFileId = group.DriverGuranteeFileId; GroupGuranteeFileId = group.GroupGuranteeFileId; MainImageBase64 = group.MainImage?.ToBase64String(); LicenseImageBase64 = group.LicenseImage?.ToBase64String(); ExtraImage1Base64 = group.ExtraImage1?.ToBase64String(); ExtraImage2Base64 = group.ExtraImage2?.ToBase64String(); ExtraImage3Base64 = group.ExtraImage3?.ToBase64String(); VehicleCount = group.Vehicles?.Count ?? 0; DriverCount = group.Drivers?.Count ?? 0; SecuremanCount = group.Drivers?.Count ?? 0; DriverInvalidCount = group.Drivers?.Count(d => !d.IsValid()) ?? 0; VehicleInvalidCount = group.Vehicles?.Count(v => !v.IsValid()) ?? 0; IsValid = group.IsValid(); }