Beispiel #1
0
        public TrainingDayDTO SaveTrainingDay(Token token, TrainingDayDTO day)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);

            //var test=service.SaveTrainingDay(token,);
            throw new NotImplementedException();
        }
Beispiel #2
0
        public PagedResult <ExerciseDTO> GetExercises(Token token, ExerciseSearchCriteria searchCriteria, PartialRetrievingInfo retrievingInfo)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);
            V2.Model.Token v2token = new V2.Model.Token(token.SessionId, token.Language);
            V2.Model.ExerciseSearchCriteria crit = new V2.Model.ExerciseSearchCriteria();
            V2.Model.PartialRetrievingInfo  nfo  = new V2.Model.PartialRetrievingInfo();
            crit = Mapper.Map <V2.Model.ExerciseSearchCriteria>(searchCriteria);
            nfo  = Mapper.Map <V2.Model.PartialRetrievingInfo>(retrievingInfo);

            var res = service.GetExercises(v2token, crit, nfo);
            var ret = Mapper.Map <V2.Model.PagedResult <V2.Model.ExerciseDTO>, PagedResult <ExerciseDTO> >(res);

            return(ret);
        }
Beispiel #3
0
        public ProfileInformationDTO GetProfileInformation(Token token, GetProfileInformationCriteria criteria)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);
            V2.Model.Token v2token = new V2.Model.Token(token.SessionId, token.Language);
            V2.Model.GetProfileInformationCriteria v2Crit = new V2.Model.GetProfileInformationCriteria();
            //v2Crit.UserId
            int? tempId;
            Guid?tempGuid;

            if ((tempGuid = h.GetGuidFromInt(criteria)) == null)
            {
                tempGuid = null;
            }
            v2Crit.UserId = tempGuid;
            var res = service.GetProfileInformation(v2token, v2Crit);

            ProfileInformationDTO profile = new ProfileInformationDTO();

            profile.AboutInformation = res.AboutInformation;
            profile.Birthday         = res.Birthday;

            foreach (V2.Model.UserSearchDTO u in res.FavoriteUsers)
            {
                UserSearchDTO a = new UserSearchDTO();
                a.CountryId = u.CountryId;
                //a.CreationDate = u.CreationDate;
                SetProperty(a, "CreationDate", u.CreationDate);
                a.Gender = (BodyArchitect.Service.Model.Gender)u.Gender;
                //a.Id = u.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(u.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.GlobalId.ToString());
                }

                //a.IsDeleted = u.IsDeleted;
                SetProperty(a, "IsDeleted", u.IsDeleted);
                //a.Picture = u.Picture;
                a.Picture = new PictureInfoDTO();
                if (u.Picture != null)
                {
                    a.Picture.Hash      = u.Picture.Hash;
                    a.Picture.PictureId = u.Picture.PictureId;
                    a.Picture.SessionId = u.Picture.SessionId;
                }
                else
                {
                    a.Picture = null;
                }
                a.Privacy.BirthdayDate          = (BodyArchitect.Service.Model.Privacy)u.Privacy.BirthdayDate;
                a.Privacy.CalendarView          = (BodyArchitect.Service.Model.Privacy)u.Privacy.CalendarView;
                a.Privacy.Friends               = (BodyArchitect.Service.Model.Privacy)u.Privacy.Friends;
                a.Privacy.Searchable            = u.Privacy.Searchable;
                a.Privacy.Sizes                 = (BodyArchitect.Service.Model.Privacy)u.Privacy.Sizes;
                a.Statistics.A6WEntriesCount    = u.Statistics.A6WEntriesCount;
                a.Statistics.A6WFullCyclesCount = u.Statistics.A6WFullCyclesCount;
                a.Statistics.BlogCommentsCount  = u.Statistics.TrainingDayCommentsCount;
                a.Statistics.BlogEntriesCount   = u.Statistics.BlogEntriesCount;
                a.Statistics.FollowersCount     = u.Statistics.FollowersCount;
                a.Statistics.FriendsCount       = u.Statistics.FriendsCount;
                //a.Statistics.Id
                if ((tempId = h.GetIntFromGuid(u.Statistics.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u.Statistics);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.Statistics.GlobalId.ToString());
                }
                //a.Statistics.IsNew
                a.Statistics.LastEntryDate                = u.Statistics.LastEntryDate;
                a.Statistics.LastLoginDate                = u.Statistics.LastLoginDate;
                a.Statistics.LoginsCount                  = u.Statistics.LoginsCount;
                a.Statistics.MyBlogCommentsCount          = u.Statistics.MyTrainingDayCommentsCount;
                a.Statistics.SizeEntriesCount             = u.Statistics.SizeEntriesCount;
                a.Statistics.StrengthTrainingEntriesCount = u.Statistics.StrengthTrainingEntriesCount;
                a.Statistics.SupplementEntriesCount       = u.Statistics.SupplementEntriesCount;
                a.Statistics.Tag = u.Statistics.Tag;
                a.Statistics.TrainingDaysCount = u.Statistics.TrainingDaysCount;
                a.Statistics.VotingsCount      = u.Statistics.VotingsCount;
                a.Statistics.WorkoutPlansCount = u.Statistics.WorkoutPlansCount;
                a.UserName = u.UserName;
                profile.FavoriteUsers.Add(a);
            }


            //profile.Friends = res.Friends;
            foreach (V2.Model.UserSearchDTO u in res.Friends)
            {
                UserSearchDTO a = new UserSearchDTO();
                a.CountryId = u.CountryId;
                //a.CreationDate = u.CreationDate;
                SetProperty(a, "CreationDate", u.CreationDate);
                a.Gender = (BodyArchitect.Service.Model.Gender)u.Gender;
                //a.Id = u.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(u.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.GlobalId.ToString());
                }

                //a.IsDeleted = u.IsDeleted;
                SetProperty(a, "IsDeleted", u.IsDeleted);
                //a.Picture = u.Picture;
                a.Picture = new PictureInfoDTO();
                if (u.Picture != null)
                {
                    a.Picture.Hash      = u.Picture.Hash;
                    a.Picture.PictureId = u.Picture.PictureId;
                    a.Picture.SessionId = u.Picture.SessionId;
                }
                else
                {
                    a.Picture = null;
                }
                a.Privacy.BirthdayDate          = (BodyArchitect.Service.Model.Privacy)u.Privacy.BirthdayDate;
                a.Privacy.CalendarView          = (BodyArchitect.Service.Model.Privacy)u.Privacy.CalendarView;
                a.Privacy.Friends               = (BodyArchitect.Service.Model.Privacy)u.Privacy.Friends;
                a.Privacy.Searchable            = u.Privacy.Searchable;
                a.Privacy.Sizes                 = (BodyArchitect.Service.Model.Privacy)u.Privacy.Sizes;
                a.Statistics.A6WEntriesCount    = u.Statistics.A6WEntriesCount;
                a.Statistics.A6WFullCyclesCount = u.Statistics.A6WFullCyclesCount;
                a.Statistics.BlogCommentsCount  = u.Statistics.TrainingDayCommentsCount;
                a.Statistics.BlogEntriesCount   = u.Statistics.BlogEntriesCount;
                a.Statistics.FollowersCount     = u.Statistics.FollowersCount;
                a.Statistics.FriendsCount       = u.Statistics.FriendsCount;
                //a.Statistics.Id
                if ((tempId = h.GetIntFromGuid(u.Statistics.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(u.Statistics);
                }
                if (tempId != null)
                {
                    a.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", u.Statistics.GlobalId.ToString());
                }
                //a.Statistics.IsNew
                a.Statistics.LastEntryDate                = u.Statistics.LastEntryDate;
                a.Statistics.LastLoginDate                = u.Statistics.LastLoginDate;
                a.Statistics.LoginsCount                  = u.Statistics.LoginsCount;
                a.Statistics.MyBlogCommentsCount          = u.Statistics.MyTrainingDayCommentsCount;
                a.Statistics.SizeEntriesCount             = u.Statistics.SizeEntriesCount;
                a.Statistics.StrengthTrainingEntriesCount = u.Statistics.StrengthTrainingEntriesCount;
                a.Statistics.SupplementEntriesCount       = u.Statistics.SupplementEntriesCount;
                a.Statistics.Tag = u.Statistics.Tag;
                a.Statistics.TrainingDaysCount = u.Statistics.TrainingDaysCount;
                a.Statistics.VotingsCount      = u.Statistics.VotingsCount;
                a.Statistics.WorkoutPlansCount = u.Statistics.WorkoutPlansCount;
                a.UserName = u.UserName;
                profile.FavoriteUsers.Add(a);
            }

            //profile.Invitations =  res.Invitations;
            foreach (V2.Model.FriendInvitationDTO c in res.Invitations)
            {
                Model.FriendInvitationDTO a = new FriendInvitationDTO();
                a.CreatedDateTime   = c.CreatedDateTime;
                a.InvitationType    = (BodyArchitect.Service.Model.InvitationType)c.InvitationType;
                a.Invited.CountryId = c.Invited.CountryId;
                //a.Invited.Id
                SetProperty(a.Invited, "CreationDate", c.Invited.CreationDate);
                a.Invited.Gender = (BodyArchitect.Service.Model.Gender)c.Invited.Gender;
                //a.Id = c.Invited.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(c.Invited.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(c.Invited);
                }
                if (tempId != null)
                {
                    a.Invited.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", c.Invited.GlobalId.ToString());
                }

                //a.IsDeleted = c.Invited.IsDeleted;
                SetProperty(a.Invited, "IsDeleted", c.Invited.IsDeleted);
                //a.Picture = c.Invited.Picture;
                a.Invited.Picture = new PictureInfoDTO();
                if (c.Invited.Picture != null)
                {
                    a.Invited.Picture.Hash      = c.Invited.Picture.Hash;
                    a.Invited.Picture.PictureId = c.Invited.Picture.PictureId;
                    a.Invited.Picture.SessionId = c.Invited.Picture.SessionId;
                }
                else
                {
                    a.Invited.Picture = null;
                }
                a.Invited.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.BirthdayDate;
                a.Invited.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.CalendarView;
                a.Invited.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.Friends;
                a.Invited.Privacy.Searchable   = c.Invited.Privacy.Searchable;
                a.Invited.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)c.Invited.Privacy.Sizes;
                a.Invited.UserName             = c.Invited.UserName;



                a.Inviter.CountryId = c.Inviter.CountryId;
                //a.Inviter.Id
                SetProperty(a.Inviter, "CreationDate", c.Inviter.CreationDate);
                a.Inviter.Gender = (BodyArchitect.Service.Model.Gender)c.Inviter.Gender;
                //a.Id = c.Inviter.GlobalId;
                tempId = null;
                if ((tempId = h.GetIntFromGuid(c.Inviter.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(c.Inviter);
                }
                if (tempId != null)
                {
                    a.Inviter.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", c.Inviter.GlobalId.ToString());
                }

                //a.IsDeleted = c.Inviter.IsDeleted;
                SetProperty(a.Inviter, "IsDeleted", c.Inviter.IsDeleted);
                //a.Picture = c.Inviter.Picture;
                a.Inviter.Picture = new PictureInfoDTO();
                if (c.Inviter.Picture != null)
                {
                    a.Inviter.Picture.Hash      = c.Inviter.Picture.Hash;
                    a.Inviter.Picture.PictureId = c.Inviter.Picture.PictureId;
                    a.Inviter.Picture.SessionId = c.Inviter.Picture.SessionId;
                }
                else
                {
                    a.Inviter.Picture = null;
                }
                a.Inviter.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.BirthdayDate;
                a.Inviter.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.CalendarView;
                a.Inviter.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.Friends;
                a.Inviter.Privacy.Searchable   = c.Inviter.Privacy.Searchable;
                a.Inviter.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)c.Inviter.Privacy.Sizes;
                a.Inviter.UserName             = c.Inviter.UserName;

                a.Message = c.Message;
                profile.Invitations.Add(a);
            }


            profile.IsActivated       = res.IsActivated;
            profile.LastLogin         = res.LastLogin;
            profile.Messages          = null; //?
            profile.RetrievedDateTime = res.RetrievedDateTime;
            //profile.Settings = res.Settings;

            profile.Settings = new ProfileSettingsDTO();
            tempId           = null;
            if ((tempId = h.GetIntFromGuid(res.Settings.GlobalId)) == null)
            {
                tempId = h.SetIntFromGuid(res.Settings);
            }
            if (tempId != null)
            {
                profile.Settings.Id = (int)tempId;
            }
            else
            {
                throw new ArgumentException("Id not assigned to guid", res.Settings.GlobalId.ToString());
            }
            //profile.Role = res.Profile.
            profile.Settings.AutomaticUpdateMeasurements = res.Settings.AutomaticUpdateMeasurements;
            //profile.Settings.Id = res.Profile.Settings.GlobalId;

            //SetProperty(profile.Settings, "IsNew", res.Profile.Settings.IsNew);
            //profile.Settings.IsNew = res.Profile.Settings.IsNew;
            //TODO:check notifications
            profile.Settings.NotificationBlogCommentAdded      = res.Settings.NotificationBlogCommentAdded != BodyArchitect.Service.V2.Model.ProfileNotification.None;
            profile.Settings.NotificationExerciseVoted         = res.Settings.NotificationVoted != BodyArchitect.Service.V2.Model.ProfileNotification.None; //??
            profile.Settings.NotificationFriendChangedCalendar = res.Settings.NotificationFriendChangedCalendar != BodyArchitect.Service.V2.Model.ProfileNotification.None;
            profile.Settings.NotificationWorkoutPlanVoted      = res.Settings.NotificationVoted != BodyArchitect.Service.V2.Model.ProfileNotification.None; //??

            profile.User           = new UserSearchDTO();
            profile.User.CountryId = res.User.CountryId;
            SetProperty(profile.User, "CreationDate", res.User.CreationDate);
            profile.User.Gender = (BodyArchitect.Service.Model.Gender)res.User.Gender;
            //a.Id = res.User.GlobalId;
            tempId = null;
            if ((tempId = h.GetIntFromGuid(res.User.GlobalId)) == null)
            {
                tempId = h.SetIntFromGuid(res.User);
            }
            if (tempId != null)
            {
                profile.User.Id = (int)tempId;
            }
            else
            {
                throw new ArgumentException("Id not assigned to guid", res.User.GlobalId.ToString());
            }

            //a.IsDeleted = res.User.IsDeleted;
            SetProperty(profile.User, "IsDeleted", res.User.IsDeleted);
            //a.Picture = res.User.Picture;
            profile.User.Picture = new PictureInfoDTO();
            if (res.User.Picture != null)
            {
                profile.User.Picture.Hash      = res.User.Picture.Hash;
                profile.User.Picture.PictureId = res.User.Picture.PictureId;
                profile.User.Picture.SessionId = res.User.Picture.SessionId;
            }
            else
            {
                profile.User.Picture = null;
            }
            profile.User.Privacy.BirthdayDate = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.BirthdayDate;
            profile.User.Privacy.CalendarView = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.CalendarView;
            profile.User.Privacy.Friends      = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.Friends;
            profile.User.Privacy.Searchable   = res.User.Privacy.Searchable;
            profile.User.Privacy.Sizes        = (BodyArchitect.Service.Model.Privacy)res.User.Privacy.Sizes;
            profile.User.UserName             = res.User.UserName;


            profile.Wymiary = new WymiaryDTO();
            if (res.Wymiary != null)
            {
                profile.Wymiary.DateTime = res.Wymiary.Time.DateTime;

                profile.Wymiary.Height = (int)res.Wymiary.Height;   //possible loss of data
                tempId = null;
                if ((tempId = h.GetIntFromGuid(res.Wymiary.GlobalId)) == null)
                {
                    tempId = h.SetIntFromGuid(res.Wymiary);
                }
                if (tempId != null)
                {
                    profile.Wymiary.Id = (int)tempId;
                }
                else
                {
                    throw new ArgumentException("Id not assigned to guid", res.Wymiary.GlobalId.ToString());
                }
                //profile.Wymiary.IsEmpty = res.Wymiary.IsEmpty; //READ ONLY
                profile.Wymiary.IsNaCzczo = false;  //res.Wymiary.????
                //profile.Wymiary.IsNew = res.Wymiary.IsNew;    //READ ONLY
                profile.Wymiary.Klatka       = (float)res.Wymiary.Klatka;
                profile.Wymiary.LeftBiceps   = (float)res.Wymiary.LeftBiceps;
                profile.Wymiary.LeftForearm  = (float)res.Wymiary.LeftForearm;
                profile.Wymiary.LeftUdo      = (float)res.Wymiary.LeftUdo;
                profile.Wymiary.Pas          = (float)res.Wymiary.Pas;
                profile.Wymiary.RightBiceps  = (float)res.Wymiary.RightBiceps;
                profile.Wymiary.RightForearm = (float)res.Wymiary.RightForearm;
                profile.Wymiary.RightUdo     = (float)res.Wymiary.RightUdo;
                profile.Wymiary.Tag          = res.Wymiary.Tag;
                profile.Wymiary.Weight       = (float)res.Wymiary.Weight;
            }
            return(profile);
        }