Esempio n. 1
0
        public static UserCondition ToAppModel(ServiceData.Models.UserCondition given, bool includeOwner)
        {
            UserCondition cond = new UserCondition
            {
                Id         = given.Id,
                Passcode   = given.Passcode,
                StartDate  = given.StartDate,
                Treatment  = given.Treatment,
                Condition  = given.Condition,
                Finished   = given.Finished,
                SkinRegion = SkinRegion.ToAppModel(given.SkinRegion, true),
                Photos     = new List <Photo>()
            };

            if (includeOwner && given.Owner != null)
            {
                cond.Owner = User.ToAppModel(given.Owner);
            }

            if (given.Photos == null)
            {
                return(cond);
            }

            List <ServiceData.Models.Photo> photos = given.Photos.ToList();

            foreach (ServiceData.Models.Photo p in photos)
            {
                cond.Photos.Add(Photo.ToAppModel(p, false));
            }

            return(cond);
        }
Esempio n. 2
0
        public static Share ToAppModel(ServiceData.Models.Share given, bool includeOwner)
        {
            if (given == null)
            {
                return(null);
            }

            Share appShare = new Share
            {
                Id          = given.Id,
                CreatedAt   = given.CreatedAt,
                ExpireDate  = given.ExpireDate,
                SharedEmail = given.SharedEmail,
                Updated     = given.Updated
            };

            if (given.Owner != null && includeOwner)
            {
                appShare.Owner = User.ToAppModel(given.Owner);
            }

            if (given.UserCondition != null)
            {
                appShare.UserCondition = UserCondition.ToAppModel(given.UserCondition, true);
            }

            return(appShare);
        }
Esempio n. 3
0
        public static User ToAppModel(ServiceData.Models.User given)
        {
            if (given == null)
            {
                return(null);
            }

            User appUser = new User
            {
                Id         = given.Id,
                BirthDate  = given.BirthDate,
                Name       = given.Name,
                Conditions = new List <UserCondition>(),
                Email      = given.Email,
                Admin      = given.Admin
            };

            if (given.Conditions != null)
            {
                foreach (ServiceData.Models.UserCondition cond in given.Conditions.ToList())
                {
                    appUser.Conditions.Add(UserCondition.ToAppModel(cond, true));
                }
            }

            if (given.Shares != null)
            {
                List <Share> shares = new List <Share>();
                foreach (ServiceData.Models.Share sh in given.Shares)
                {
                    shares.Add(Share.ToAppModel(sh, false));
                }
                appUser.Shares = shares;
            }

            if (given.ManagedStudies != null)
            {
                List <Study> studies = new List <Study>();
                foreach (ServiceData.Models.Study st in given.ManagedStudies)
                {
                    studies.Add(Study.ToAppModel(st, false));
                }
                appUser.ManagedStudies = studies;
            }

            if (given.StudyEnrolments != null)
            {
                List <StudyEnrolment> enrolled = new List <StudyEnrolment>();
                foreach (ServiceData.Models.StudyEnrolment st in given.StudyEnrolments)
                {
                    enrolled.Add(StudyEnrolment.ToAppModel(st, true, false));
                }
                appUser.StudyEnrolments = enrolled;
            }

            return(appUser);
        }
Esempio n. 4
0
        public static ServiceData.Models.User ToServiceModel(User given)
        {
            ServiceData.Models.User serviceUser = new ServiceData.Models.User
            {
                Id        = given.Id,
                BirthDate = given.BirthDate,
                Name      = given.Name,
                Email     = given.Email,
                Admin     = given.Admin
            };

            if (given.Conditions != null)
            {
                List <ServiceData.Models.UserCondition> conditions = new List <ServiceData.Models.UserCondition>();
                foreach (UserCondition cond in given.Conditions)
                {
                    conditions.Add(UserCondition.ToServiceModel(cond, true));
                }
                serviceUser.Conditions = conditions;
            }

            if (given.Shares != null)
            {
                List <ServiceData.Models.Share> shares = new List <ServiceData.Models.Share>();
                foreach (Share sh in given.Shares)
                {
                    shares.Add(Share.ToServiceModel(sh, false));
                }
                serviceUser.Shares = shares;
            }

            if (given.ManagedStudies != null)
            {
                List <ServiceData.Models.Study> studies = new List <ServiceData.Models.Study>();
                foreach (Study st in given.ManagedStudies)
                {
                    studies.Add(Study.ToServiceModel(st, false));
                }
                serviceUser.ManagedStudies = studies;
            }

            if (given.StudyEnrolments != null)
            {
                List <ServiceData.Models.StudyEnrolment> enrolled = new List <ServiceData.Models.StudyEnrolment>();
                foreach (StudyEnrolment st in given.StudyEnrolments)
                {
                    enrolled.Add(StudyEnrolment.ToServiceModel(st, true, false));
                }
                serviceUser.StudyEnrolments = enrolled;
            }

            return(serviceUser);
        }