public LicenseViewModel(LicenseExportFromDatabase l_exp) { License l = l_exp.license; Id = l.Id; LicenseNom = l.Nom; NomOfBook = l.NomOfBook; LicenseDateStart = l.DateStart.ToShortDateString(); LicenseDateExpired = l.DateExpired.ToShortDateString(); LicenseStatusRus = LicenseViewModelForCompany.GetRusLicenseStatus(l.Status); Company c = l_exp.company; CompanyId = c.Id; CompanyShortName = c.ShortName; CompanyINN = c.INN; CompanyKPP = c.KPP; CompanyOGRN = c.ORGN; CompanyAddress = c.ActualAddrStr; CompanyEmail = c.Email; ActionWithLicense a = l_exp.last_action; if (a != null) { LastActionDate = a.DateTimeAction.ToShortDateString(); LastActionReason = a.Reason; } else { LastActionDate = ""; LastActionReason = ""; } LicenseForm lf = l_exp.last_license_form; if (lf != null) { LastLicenseFormNom = lf.Nom; } else { LastLicenseFormNom = ""; } }
public ActionWithLicenseWithLicenseFormViewModel(ActionWithLicense awl) { IdAction = awl.Id; Reason = awl.Reason; DateAction = awl.DateTimeAction.ToShortDateString(); IsSelected = false; HasResolution = awl.Resolution != null; if (HasResolution) { ResolutionId = awl.Resolution.Id; ResolutionNom = awl.Resolution.RegNomAll; } HasLicenseForm = awl.LicenseForm != null; if (HasLicenseForm) { LicenseForm lf = awl.LicenseForm; IdLicenseForm = lf.Id; Nom = lf.Nom; CompanyName = lf.FullNameCompany; CompanyAddress = lf.AddressCompany; Email = lf.Email; DateExpired = lf.DateExpired.ToShortDateString(); Units = new List <UnitInLicenseFormViewModelShort>(); foreach (var u in lf.UnitsInLicenseForm.OrderBy(j => j.Address)) { Units.Add(new UnitInLicenseFormViewModelShort() { Id = u.Id, Address = u.Address }); } } else { Nom = ""; CompanyName = ""; CompanyAddress = ""; Email = ""; DateExpired = ""; Units = new List <UnitInLicenseFormViewModelShort>(); } }