public IServiceResultWrap GetOrganizationStatus([FromBody] VmOrganizationModel model) { return(serviceManager.CallService( () => new ServiceLocalizedResultWrap(model) { Data = organizationService.GetOrganizationStatus(model.Id.Value) }, new Dictionary <Type, string>())); }
public IServiceResultWrap SaveAllChanges([FromBody] VmOrganizationModel model) { return(serviceManager.CallService( () => new ServiceLocalizedResultWrap(model) { Data = organizationService.AddApiOrganization(model) }, new Dictionary <Type, string>() { { typeof(string), MessageAddOrganization }, { typeof(PtvArgumentException), MessageArgumentDuplicityException }, { typeof(RoleActionException), MessageAddOrganizationRole }, { typeof(PtvServiceArgumentException), MessageArgumentOrganizationTypeException }, { typeof(OrganizationCyclicDependencyException), MessageOrganizationCyclicDependency } } )); }
private void CheckTranslation(VmOrganizationModel source, VmOrganizationStep1 step1, OrganizationVersioned target) { target.Id.Should().NotBe(Guid.Empty); var names = conversion.GetValidTextsSkipEmpty(step1.OrganizationName, step1.OrganizationAlternateName); target.OrganizationNames.Count.Should().Be(Math.Max(names.Count, 1), "OrganizationNames"); var descriptions = conversion.GetValidTexts(step1.Description); target.OrganizationDescriptions.Count.Should().Be(descriptions.Count, "OrganizationDescriptions"); if (step1.ParentId.HasValue) { target.ParentId.Should().NotBeEmpty(); target.ParentId.Should().Be(step1.ParentId.Value); } if (step1.Municipality?.Id != null) { target.MunicipalityId.Should().NotBeEmpty(); target.MunicipalityId.Should().Be(step1.Municipality?.Id); } if (step1.OrganizationTypeId.HasValue) { target.TypeId.Should().NotBeEmpty(); target.TypeId.Should().Be(step1.OrganizationTypeId.Value); } if (step1.ShowContacts) { target.OrganizationEmails.Count.Should().Be(step1.Emails.Count, "Emails"); target.OrganizationPhones.Count.Should().Be(step1.PhoneNumbers.Count, "Phone"); target.OrganizationWebAddress.Count.Should().Be(step1.WebPages.Count, "Web pages"); if (step1.ShowPostalAddress || step1.ShowVisitingAddress) { target.OrganizationAddresses.Count.Should().Be(step1.PostalAddresses.Count + step1.VisitingAddresses.Count, "Adresses"); } } }
private void SetStep1Translation(ITranslationDefinitions <VmOrganizationModel, OrganizationVersioned> definition, VmOrganizationModel organization) { //var model = organization.Step1Form; //var names = new List<VmName>() //{ // new VmName {Name = model.OrganizationName, TypeId = typesCache.Get<NameType>(NameTypeEnum.Name.ToString()), OwnerReferenceId = organization.Id} //}; //if (!string.IsNullOrEmpty(model.OrganizationAlternateName) || (model.DisplayNameId == typesCache.Get<NameType>(NameTypeEnum.AlternateName.ToString()))) //{ // names.Add(new VmName { Name = model.OrganizationAlternateName, TypeId = typesCache.Get<NameType>(NameTypeEnum.AlternateName.ToString()), OwnerReferenceId = organization.Id }); //} //var descriptions = new List<VmDescription>() //{ // new VmDescription { Description = model.Description, TypeId = typesCache.Get<DescriptionType>(DescriptionTypeEnum.Description.ToString()), OwnerReferenceId = organization.Id}, //}; //definition.AddNavigation(i => i.Step1Form.Business, o => o.Business); //if (model.OrganizationTypeId.IsAssigned() && typesCache.Compare<AreaInformationType>(model.AreaInformationTypeId, AreaInformationTypeEnum.AreaType.ToString())) //{ // if (typesCache.Compare<OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.State.ToString()) || // typesCache.Compare<OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.Organization.ToString()) || // typesCache.Compare<OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.Company.ToString()) || // typesCache.Compare<OrganizationType>(model.OrganizationTypeId, OrganizationTypeEnum.RegionalOrganization.ToString())) // { // var areas = model.BusinessRegions.Union(model.HospitalRegions).Union(model.Provinces); // definition.AddCollection(i => areas.Select(x => new VmListItem { Id = x, OwnerReferenceId = organization.Id }), o => o.OrganizationAreas); // definition.AddCollection(i => i.Step1Form.Municipalities.Select(x => new VmListItem { Id = x, OwnerReferenceId = organization.Id }), o => o.OrganizationAreaMunicipalities); // } //} //else //{ //Remove Areas // definition.AddCollection(i => new List<VmListItem>() {}, o => o.OrganizationAreas); // definition.AddCollection(i => new List<VmListItem>() {}, o => o.OrganizationAreaMunicipalities); //} //var nameType = new VmDispalyNameType { NameTypeId = model.DisplayNameId, OwnerReferenceId = organization.Id }; //var order = 1; //model.Emails.ForEach(email => email.OrderNumber = order++); //order = 1; //model.PhoneNumbers.ForEach(phone => phone.OrderNumber = order++); //order = 1; //model.VisitingAddresses.ForEach(item => item.OrderNumber = order++); //order = 1; //model.PostalAddresses.ForEach(item => item.OrderNumber = order++); //var defaultAreaInformationTypeId = typesCache.Get<AreaInformationType>(AreaInformationTypeEnum.WholeCountry.ToString()); // definition // .AddSimple(i => i.Step1Form.OrganizationTypeId, o => o.TypeId) // .AddSimple(i => i.Step1Form.AreaInformationTypeId.IsAssigned() ? i.Step1Form.AreaInformationTypeId : defaultAreaInformationTypeId, output => output.AreaInformationTypeId) // .AddSimple(i => i.Step1Form.ParentId, o => o.ParentId) // .AddSimple(i => i.Step1Form.Municipality?.Id, o => o.MunicipalityId) //.AddSimple(i => i.Step1Form.DisplayNameId, o => o.DisplayNameTypeId) //.AddNavigation(i => i.Step1Form.OrganizationId, o => o.Oid) // .AddLocalizable(i => nameType, o => o.OrganizationDisplayNameTypes) //.AddCollectionWithKeep(i => names, o => o.OrganizationNames, TranslationPolicy.FetchData, x => x.LocalizationId != RequestLanguageId) //.AddCollectionWithKeep(i => descriptions, o => o.OrganizationDescriptions, TranslationPolicy.FetchData, x => x.LocalizationId != RequestLanguageId); //model.ShowContacts //definition // .AddCollection(i => i.Step1Form.Emails, o => o.OrganizationEmails) // .AddCollection(i => i.Step1Form.PhoneNumbers, o => o.OrganizationPhones) // .AddCollection(i => i.Step1Form.WebPages, o => o.OrganizationWebAddress); //TODO //model.ShowPostalAddress || model.ShowVisitingAddress) //var addresses = new List<VmAddressSimple>(); //addresses = model.PostalAddresses.Any() ? addresses.Concat(model.PostalAddresses.Where(x => // (x.PostalCode != null && x.StreetType != AddressTypeEnum.Foreign.ToString()) || // x.StreetType == AddressTypeEnum.Foreign.ToString())).ToList() : addresses; //addresses = model.VisitingAddresses.Any() ? addresses.Concat(model.VisitingAddresses.Where(x => // (x.PostalCode != null && x.StreetType != AddressTypeEnum.Foreign.ToString()) || // x.StreetType == AddressTypeEnum.Foreign.ToString())).ToList() : addresses; //addresses.ForEach(x => x.OwnerReferenceId = organization.Id); //definition.AddCollection(i => addresses, o => o.OrganizationAddresses); }