public async Task <ImlAppDetailDTO> GetEditPortal(Guid?id, IDictionary <string, string> paramList) { var checkSort = paramList.TryGetValue("sort", out var sort); ImlAppDetailDTO model; if (id == null || id == Guid.Empty) { model = new ImlAppDetailDTO(); var userInfo = await _userInfoService.GetCurrentUserInfoAsync(); model.AppSort = !checkSort ? "GetLicenseApplication" : sort; if (!string.IsNullOrEmpty(userInfo?.EDRPOU())) { model.EDRPOU = userInfo?.EDRPOU(); model.OrgName = userInfo?.OrganizationName(); } else { model.INN = userInfo?.INN(); model.OrgName = userInfo?.FullName(); } } else { model = (await DataService.GetDtoAsync <ImlAppDetailDTO>(x => x.Id == id)).FirstOrDefault(); } return(model); }
public async Task BackCreateApplication(ImlAppDetailDTO model, Guid?orgId, string sort) { if (orgId == null) { throw new Exception(); } var organizationInfo = DataService.GetEntity <OrganizationInfo>(x => x.IsActualInfo && x.OrganizationId == orgId) .FirstOrDefault(); _objectMapper.Map(organizationInfo, model); var address = DataService.GetDto <AtuSubjectAddressDTO>(x => x.Id == model.AddressId).FirstOrDefault(); if (address != null) { _objectMapper.Map(address, model); } model.Id = Guid.Empty; model.AppSort = sort; var org = DataService.GetEntity <OrganizationExt>(x => x.Id == orgId).FirstOrDefault(); if (org == null) { throw new Exception(); } if (!string.IsNullOrEmpty(org.EDRPOU)) { model.EDRPOU = org.EDRPOU; } else { model.INN = org.INN; } model.OrgUnitId = orgId.Value; // Тут работал Макс // model.EMail = org.EMail; }
public async Task <Guid> SaveApplication(ImlAppDetailDTO editModel, bool isBackOffice = false) { Guid appId; var userInfo = await _userInfoService?.GetCurrentUserInfoAsync(); var isNew = false; if (editModel.Id == Guid.Empty) { isNew = true; var model = new ImlAppDetailDTO(); _objectMapper.Map(editModel, model); if (model.OrgUnitId == Guid.Empty) { model.OrgUnitId = new Guid(userInfo.OrganizationId()); } if (isBackOffice) { model.IsCreatedOnPortal = false; model.BackOfficeAppState = "Project"; } else { model.AppState = "Project"; model.IsCreatedOnPortal = true; } model.AppType = "IML"; var organizationInfo = new OrganizationInfo(); organizationInfo.OrganizationId = model.OrgUnitId == Guid.Empty ? new Guid(userInfo?.OrganizationId()) : model.OrgUnitId; organizationInfo.Type = "IML"; if (string.IsNullOrEmpty(model.EDRPOU)) { if (isBackOffice == false) { organizationInfo.OrgDirector = userInfo.FullName(); } } else { organizationInfo.OrgDirector = model.OrgDirector; } organizationInfo.Name = model.OrgName; organizationInfo.LegalFormType = model.LegalFormType; organizationInfo.OwnershipType = model.OwnershipType; organizationInfo.PhoneNumber = model.PhoneNumber; organizationInfo.FaxNumber = model.FaxNumber; organizationInfo.NationalAccount = model.NationalAccount; organizationInfo.InternationalAccount = model.InternationalAccount; organizationInfo.NationalBankRequisites = model.NationalBankRequisites; organizationInfo.InternationalBankRequisites = model.InternationalBankRequisites; organizationInfo.PassportSerial = model.PassportSerial; organizationInfo.PassportNumber = model.PassportNumber; organizationInfo.PassportDate = model.PassportDate; organizationInfo.PassportIssueUnit = model.PassportIssueUnit; organizationInfo.AddressId = model.AddressId; //var license = _prlLicenseService.GetLicenseGuid(model.OrgUnitId); //if (license == null) //{ // if (editModel.AppSort == "AdditionalInfoToLicense") // organizationInfo.IsPendingLicenseUpdate = true; // organizationInfo.IsActualInfo = true; // DataService.GetEntity<OrganizationInfo>(x => // x.IsActualInfo && x.OrganizationId == model.OrgUnitId && x.Type == "PRL").ToList() // .ForEach(x => x.IsActualInfo = false); //} DataService.Add(organizationInfo); DataService.SaveChanges(); model.OrganizationInfoId = organizationInfo.Id; var organization = DataService.GetEntity <OrganizationExt>() .SingleOrDefault(x => x.Id == model.OrgUnitId); if (string.IsNullOrEmpty(model.EDRPOU)) { organization.INN = model.INN; } organization.EMail = model.EMail; appId = DataService.Add <ImlApplication>(model); await DataService.SaveChangesAsync(); } else { if (isBackOffice) { editModel.IsCreatedOnPortal = false; editModel.BackOfficeAppState = "Project"; } else { editModel.AppState = "Project"; editModel.IsCreatedOnPortal = true; } var organizationInfo = DataService.GetEntity <OrganizationInfo>() .SingleOrDefault(x => x.Id == editModel.OrganizationInfoId); organizationInfo.LegalFormType = editModel.LegalFormType; organizationInfo.OwnershipType = editModel.OwnershipType; organizationInfo.PhoneNumber = editModel.PhoneNumber; organizationInfo.FaxNumber = editModel.FaxNumber; organizationInfo.NationalAccount = editModel.NationalAccount; organizationInfo.InternationalAccount = editModel.InternationalAccount; organizationInfo.NationalBankRequisites = editModel.NationalBankRequisites; organizationInfo.InternationalBankRequisites = editModel.InternationalBankRequisites; organizationInfo.PassportSerial = editModel.PassportSerial; organizationInfo.PassportNumber = editModel.PassportNumber; organizationInfo.PassportDate = editModel.PassportDate; organizationInfo.PassportIssueUnit = editModel.PassportIssueUnit; organizationInfo.OrgDirector = editModel.OrgDirector; organizationInfo.AddressId = editModel.AddressId; var organization = DataService.GetEntity <OrganizationExt>() .SingleOrDefault(x => x.Id == editModel.OrgUnitId); organization.EMail = editModel.EMail; appId = DataService.Add <ImlApplication>(editModel); await DataService.SaveChangesAsync(); } //if (editModel.AppSort == "AdditionalInfoToLicense" && isNew) //{ // var license = (await _limsExchangeService // .GetLicenses("PRL", string.IsNullOrEmpty(editModel.EDRPOU) ? editModel.INN : editModel.EDRPOU)).FirstOrDefault(); // if (license == null) throw new Exception(); // foreach (var branchLicense in license.Branches) // { // var branch = new Branch // { // Id = Guid.NewGuid(), // OrganizationId = editModel.OrgUnitId == Guid.Empty // ? new Guid(userInfo?.OrganizationId()) // : editModel.OrgUnitId, // OldLimsId = branchLicense.Id, // Name = branchLicense.Name // }; // var branchId = DataService.Add(branch, false); // var appBranch = new ApplicationBranch() // { // LimsDocumentId = appId, // BranchId = branchId // }; // DataService.Add(appBranch, false); // await DataService.SaveChangesAsync(); // } //} return(appId); }