public DeclarationViewModelForPack(Declaration dec, int ResolutionId) { Id = dec.Id; RegNom = dec.RegNomAll; DateDeclaration = dec.DateDeclaration.ToString(); DateStartLicense = (dec.LicenseBaseDateStart.HasValue ? dec.LicenseBaseDateStart.Value : dec.Resolution.Date).ToString(); //DateExpiredLicense = dec.LicenseBaseDateExpired?.ToString(); CountOfYears = dec.CountOfYears; CreatorName = dec.CreatorName; Comm = dec.Comm; IsSelected = dec.ResolutionId.HasValue ? dec.ResolutionId.Value == ResolutionId : false; //if (IsSelected) //{ List<UnitInDeclaration> all_unit_in_declaration = dec.UnitsInDeclaration.ToList(); UnitsAdd = UnitInDeclarationViewModel.GetListViewModel(all_unit_in_declaration.Where(j => j.Type == UnitInDeclarationType.Add).AsQueryable()); UnitsRemove = UnitInDeclarationViewModel.GetListViewModel(all_unit_in_declaration.Where(j => j.Type == UnitInDeclarationType.Remove).AsQueryable()); UnitsEdit = UnitInDeclarationViewModel.GetListViewModel(all_unit_in_declaration.Where(j => j.Type == UnitInDeclarationType.Edit).AsQueryable()); //} IsGrantType = dec.Type.HasFlag(DeclarationType.Grant); IsProlongType = dec.Type.HasFlag(DeclarationType.Prolong); IsReNewType = dec.Type.HasFlag(DeclarationType.Renew); IsCancelType = dec.Type.HasFlag(DeclarationType.Cancel); IsClone = dec.Type.HasFlag(DeclarationType.Clone); ActionDeclarationRus = DeclarationViewModel.GetRusDeclarationType(dec.Type); }
public static DeclarationViewModel GetDeclarationViewModelById(IRepository repository, int id) { Declaration d = repository.Declaration.Items.First(j => j.Id == id); // TypeOfResolution type_of_res = d.Resolution == null ? repository.TypeOfResolution.GetNotDeletedItems().First() : d.Resolution.TypeOfResolution; DeclarationViewModel result = new DeclarationViewModel(new DeclarationExportFromDatabase() { resolution = d.Resolution, // type_of_resolution = d.Resolution.TypeOfResolution, reason_for_renews = d.ReasonForRenews.ToList(), // добавил соединения с Resolution refuse_basis = d.Resolution.RefuseBasises.ToList(), license_form = d.LicenseForm, license = d.License, TypeCreateDeclaration = "Edit", declaration = d, legal_form_type = d.LegalFormType, licensed_activity_type = d.LicensedActivityType, addr = d.ActualAddr, postal_addr = d.PostalAddr, company_export = d.Company == null ? null : new CompanyExportFromDatabase() { company = d.Company } }, repository); result.UnitsAdd = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetAddItemsForDeclaration(id)); result.UnitsRemove = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetRemoveItemsForDeclaration(id)); result.UnitsEdit = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetEditItemsForDeclaration(id)); result.Revisions = RevisionViewModel.GetListViewModel(repository.Revision.GetItemsForDeclaration(id)); result.TagsTable = new ValueTagTableViewModel(d.Id, EntitiesForTag.Declaration, repository); result.Documents = DocumentViewModel.GetListViewModel(repository.Document.GetItemsForDeclaration(id)); result.PaymentOrders = PaymentOrderViewModelForDeclaration.GetListViewModel(repository.PaymentOrder.GetItemsForDeclaration(id)); result.ActionsWithDeclaration = ActionWithDeclarationViewModelForDeclaration.GetListViewModel(repository.ActionWithDeclaration.GetItemsForDeclaration(id)); int res_id = d.Resolution == null ? 0 : d.ResolutionId.Value; if (result.IsProlongType || result.IsReNewType) { result.DeclarationsInPack = DeclarationViewModelForPack.GetListViewModel(repository.Declaration.GetNotDeletedItems().Where(j => j.Id != d.Id && j.Status == DeclarationStatus.Consideration && j.CompanyId.HasValue && j.CompanyId.Value == d.CompanyId.Value && (j.Type.HasFlag(DeclarationType.Prolong) || j.Type.HasFlag(DeclarationType.Renew))), res_id); } result.ResolutionTypes = TypeOfResolutionForResolutionViewModel.GetTypeOfResolutionViewModelList(repository, d.Resolution.TypeOfType, d.Resolution); result.ResolutionCommissioners = Utils.GetPeopleListByRole(repository, "ResolutionCommissioner"); foreach (var item in result.ResolutionCommissioners) { item.IsChecked = d.Resolution.ResolutionCommissioners.Select(x => x.Id).ToList().Contains(item.Id); } //result.list_Refuse_Basis = Utils.GetPeopleListByRole(repository, "ShowRefuseBasis"); //foreach (var item in result.list_Refuse_Basis) //{ // item.IsChecked = d.Resolution.RefuseBasises.Select(x => x.Id).ToList().Contains(item.Id); //} return result; }