Exemple #1
0
        public static coreModel.Organization ToCoreModel(this webModel.Organization organization)
        {
            var retVal = new coreModel.Organization();

            retVal.InjectFrom(organization);


            if (organization.Phones != null)
            {
                retVal.Phones = organization.Phones;
            }
            if (organization.Emails != null)
            {
                retVal.Emails = organization.Emails;
            }
            if (organization.Notes != null)
            {
                retVal.Notes = organization.Notes.Select(x => x.ToCoreModel()).ToList();
            }
            if (organization.Addresses != null)
            {
                retVal.Addresses = organization.Addresses.Select(x => x.ToCoreModel()).ToList();
            }
            if (organization.DynamicProperties != null)
            {
                retVal.DynamicProperties = organization.DynamicProperties;
            }

            return(retVal);
        }
Exemple #2
0
        public coreModel.Organization Create(coreModel.Organization organization)
        {
            var entity = organization.ToDataModel();

            coreModel.Organization retVal = null;
            using (var repository = _repositoryFactory())
            {
                repository.Add(entity);
                CommitChanges(repository);
            }
            retVal = GetById(entity.Id);
            return(retVal);
        }
Exemple #3
0
        public coreModel.Organization GetById(string id)
        {
            coreModel.Organization retVal = null;
            using (var repository = _repositoryFactory())
            {
                var entity = repository.GetOrganizationById(id);
                if (entity != null)
                {
                    retVal = entity.ToCoreModel();
                }
            }

            return(retVal);
        }
Exemple #4
0
        public void CreateNewOrganization()
        {
            var controller = GetContactController();
            var org = new Organization
            {
                Id = "org2",
                BusinessCategory = "cat2",
                Name = "organization 2",
                ParentId = "org1"

            };
            var result = controller.CreateOrganization(org) as OkNegotiatedContentResult<Organization>;
            Assert.IsNotNull(result.Content);
        }
Exemple #5
0
        public coreModel.Organization Create(coreModel.Organization organization)
        {
            var entity = organization.ToDataModel();

            using (var repository = _repositoryFactory())
            {
                repository.Add(entity);
                CommitChanges(repository);
            }

            _dynamicPropertyService.SaveDynamicPropertyValues(organization);

            var retVal = GetById(entity.Id);

            return(retVal);
        }
Exemple #6
0
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.Organization ToCoreModel(this dataModel.Organization dbEntity)
        {
            if (dbEntity == null)
            {
                throw new ArgumentNullException("dbEntity");
            }

            var retVal = new coreModel.Organization();

            dbEntity.ToCoreModel(retVal);

            if (dbEntity.MemberRelations.Any())
            {
                retVal.ParentId = dbEntity.MemberRelations.FirstOrDefault().AncestorId;
            }
            return(retVal);
        }
		public static coreModel.Organization ToCoreModel(this webModel.Organization organization)
		{
			var retVal = new coreModel.Organization();
			retVal.InjectFrom(organization);


			if (organization.Phones != null)
				retVal.Phones = organization.Phones;
			if (organization.Emails != null)
				retVal.Emails = organization.Emails;
			if (organization.Notes != null)
				retVal.Notes = organization.Notes.Select(x => x.ToCoreModel()).ToList();
			if (organization.Addresses != null)
				retVal.Addresses = organization.Addresses.Select(x => x.ToCoreModel()).ToList();

			return retVal;
		}
Exemple #8
0
        public coreModel.Organization GetById(string id)
        {
            coreModel.Organization retVal = null;

            using (var repository = _repositoryFactory())
            {
                var entity = repository.GetOrganizationById(id);
                if (entity != null)
                {
                    retVal = entity.ToCoreModel();
                }
            }

            if (retVal != null)
            {
                _dynamicPropertyService.LoadDynamicPropertyValues(retVal);
            }

            return(retVal);
        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.Organization ToCoreModel(this dataModel.Organization dbEntity)
        {
            if (dbEntity == null)
                throw new ArgumentNullException("dbEntity");

            var retVal = new coreModel.Organization();
            retVal.InjectFrom(dbEntity);

            retVal.Addresses = dbEntity.Addresses.Select(x => x.ToCoreModel()).ToList();
            retVal.Emails = dbEntity.Emails.Select(x => x.Address).ToList();
            retVal.Notes = dbEntity.Notes.Select(x => x.ToCoreModel()).ToList();
            retVal.Phones = dbEntity.Phones.Select(x => x.Number).ToList();
            if (dbEntity.MemberRelations.Any())
            {
                retVal.ParentId = dbEntity.MemberRelations.FirstOrDefault().AncestorId;
            }

            return retVal;

        }
        /// <summary>
        /// Converting to model type
        /// </summary>
        /// <param name="catalogBase"></param>
        /// <returns></returns>
        public static coreModel.Organization ToCoreModel(this dataModel.Organization dbEntity)
        {
            if (dbEntity == null)
            {
                throw new ArgumentNullException("dbEntity");
            }

            var retVal = new coreModel.Organization();

            retVal.InjectFrom(dbEntity);

            retVal.Addresses = dbEntity.Addresses.Select(x => x.ToCoreModel()).ToList();
            retVal.Emails    = dbEntity.Emails.Select(x => x.Address).ToList();
            retVal.Notes     = dbEntity.Notes.Select(x => x.ToCoreModel()).ToList();
            retVal.Phones    = dbEntity.Phones.Select(x => x.Number).ToList();
            if (dbEntity.MemberRelations.Any())
            {
                retVal.ParentId = dbEntity.MemberRelations.FirstOrDefault().AncestorId;
            }

            return(retVal);
        }
Exemple #11
0
 public IHttpActionResult UpdateOrganization(coreModel.Organization organization)
 {
     return(UpdateMember(organization));
 }
        public static dataModel.Organization ToDataModel(this coreModel.Organization organization, PrimaryKeyResolvingMap pkMap)
        {
            if (organization == null)
            {
                throw new ArgumentNullException("organization");
            }

            var retVal = new dataModel.Organization();

            pkMap.AddPair(organization, retVal);

            retVal.InjectFrom(organization);

            if (organization.Phones != null)
            {
                retVal.Phones = new ObservableCollection <dataModel.Phone>(organization.Phones.Select(x => new dataModel.Phone
                {
                    Number   = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Emails != null)
            {
                retVal.Emails = new ObservableCollection <dataModel.Email>(organization.Emails.Select(x => new dataModel.Email
                {
                    Address  = x,
                    MemberId = organization.Id
                }));
            }

            if (organization.Addresses != null)
            {
                retVal.Addresses = new ObservableCollection <dataModel.Address>(organization.Addresses.Select(x => x.ToDataModel()));
                foreach (var address in retVal.Addresses)
                {
                    address.MemberId = organization.Id;
                }
            }

            if (organization.Notes != null)
            {
                retVal.Notes = new ObservableCollection <dataModel.Note>(organization.Notes.Select(x => x.ToDataModel()));
                foreach (var note in retVal.Notes)
                {
                    note.MemberId = organization.Id;
                }
            }

            if (organization.ParentId != null)
            {
                retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>();
                var memberRelation = new dataModel.MemberRelation
                {
                    AncestorId       = organization.ParentId,
                    DescendantId     = organization.Id,
                    AncestorSequence = 1
                };
                retVal.MemberRelations.Add(memberRelation);
            }
            return(retVal);
        }