Example #1
0
        public static TraineeContext ConvertToTraineeContext(this ITrainee trainee)
        {
            TraineeContext context = new TraineeContext();

            context.Id                = trainee.Id.ToString();
            context.UserName          = trainee.UserName;
            context.UserType          = trainee.UserType;
            context.Created           = trainee.Created;
            context.IsActive          = trainee.IsActive;
            context.Email             = trainee.Email;
            context.Description       = trainee.Description;
            context.Location          = trainee.Location.ConvertToLocationContext();
            context.Modified          = trainee.Modified;
            context.Password          = trainee.Password;
            context.PhoneNumber       = trainee.PhoneNumber;
            context.PhoneVisibility   = trainee.PhoneVisibility;
            context.UserVisibility    = trainee.UserVisibility;
            context.Birthday          = trainee.Birthday;
            context.Gender            = trainee.Gender;
            context.Achievements      = trainee.Challenges.ConvertToChallengesContexts();
            context.MedicalCondition  = trainee.MedicalCondition.ToMedicalConditionContext();
            context.Name              = trainee.Name;
            context.FavouriteExercise = trainee.FavouriteExercise.ConvertToExerciseContext();

            return(context);
        }
Example #2
0
 public static Trainee ConvertToTrainee(this TraineeContext context)
 {
     return(new Trainee
     {
         Id = ObjectId.Parse(context.Id.ToString()),
         UserName = context.UserName,
         UserType = context.UserType,
         Created = context.Created,
         IsActive = context.IsActive,
         Email = context.Email,
         Description = context.Description,
         Location = context.Location.ConvertToLocation(),
         Modified = context.Modified,
         Password = context.Password,
         PhoneNumber = context.PhoneNumber,
         PhoneVisibility = context.PhoneVisibility,
         UserVisibility = context.UserVisibility,
         Birthday = context.Birthday,
         FavouriteExercise = context.FavouriteExercise.ConvertToExercise(),
         Gender = context.Gender,
         Challenges = context.Achievements.ConvertToChallenges(),
         MedicalCondition = context.MedicalCondition.toMedicalCondition(),
         Name = context.Name
     });
 }
Example #3
0
        public async Task <UserTraineeProfileDataContext> ViewTraineeProfile(string userId)
        {
            TraineeContext traineeContext = await GetById(userId);

            UserTraineeProfileDataContext traineeProfileData = traineeContext.ConvertToUserProfileContext();

            return(traineeProfileData);
        }
        public async Task<ActionResult> ViewTraineeMedicalCondition(string traineeId)
        {
            ViewBag.Title = "ViewTraineeMedicalCondition";
            //string userId = Request.Cookies["userId"].Value;
            TraineeContext trainee = await traineeManager.GetById(traineeId);
            ViewBag.traineeId = traineeId;

            return View(trainee.MedicalCondition);
        }
        public async Task<ActionResult> PersonalProfile()
        {
            //ViewBag.Title = "PersonaProfileView";
            string userId = Request.Cookies["userId"].Value;

            TraineeContext trainee = await traineeManager.GetById(userId);

            return View(trainee);
        }
Example #6
0
        public async Task <UserContext> RegisterTraineeUser(string email, string password, string userName)
        {
            TraineeContext userTraineeContext = new TraineeContext(email, password, userName);

            userTraineeContext.UserType = "Trainee";
            userTraineeContext.Created  = DateTime.Now;
            var result = await SaveTrainee(userTraineeContext);

            return(result);
        }
Example #7
0
        public async Task <TraineeContext> SaveOneAsync(TraineeContext traineeContext)
        {
            if (string.IsNullOrEmpty(traineeContext.Id))
            {
                var trainee = TraineeConverter.ConvertToNewTrainee(traineeContext);
                trainee = await UserEntityService.SaveOneAsync(trainee);

                traineeContext.Id = trainee.Id.ToString();
                return(traineeContext);
            }

            var update = TraineeConverter.ConvertToTrainee(traineeContext);
            await UserEntityService.Update(update);

            return(traineeContext);
        }
Example #8
0
        public async Task <TraineeContext> SaveTrainee(TraineeContext userTraineeContext)
        {
            if (string.IsNullOrEmpty(userTraineeContext.Id))
            {
                Trainee traineeUser = new Trainee();
                traineeUser = userTraineeContext.ConvertToNewTrainee();

                var result = await userEntityService.SaveOneAsync(traineeUser);

                return(((Trainee)result).ConvertToTraineeContext());
            }
            var update = userTraineeContext.ConvertToTrainee();
            //var update = UserConverter.ConvertToTrainer(userTraineeContext);
            await userEntityService.Update(update);

            return(userTraineeContext);
        }
Example #9
0
 public static UserTraineeProfileDataContext ConvertToUserProfileContext(this TraineeContext traineeContext)
 {
     return(new UserTraineeProfileDataContext
     {
         UserId = traineeContext.Id,
         Email = traineeContext.Email,
         UserName = traineeContext.UserName,
         UserType = traineeContext.UserType,
         Gender = traineeContext.Gender,
         Name = traineeContext.Name,
         IsActive = traineeContext.IsActive,
         Location = traineeContext.Location,
         PhoneNumber = traineeContext.PhoneNumber,
         Birthday = traineeContext.Birthday,
         FavouriteExercise = traineeContext.FavouriteExercise
     });
 }
Example #10
0
        public async Task <ActionResult> UpdateTraineeProfile(TraineeContext trainee)
        {
            var result = await registerManager.SaveTrainee(trainee);

            return(RedirectToAction("Index", "Home", new { area = "" }));
        }