Beispiel #1
0
		public static async Task<UserExercisesUpdateExerciseResponseDTO> UpdateUserExercises(List<UserWorkoutTemplateMapping> exercises, int gymID, int profileID, bool isDeleted, int serverUserExerciseGroupID, string userExerciseGroupName, string userExerciseGroupDescription, int serverTemplateID = 0)
		{

			var dto = UserExercisesUpdateExerciseCreator.CreateUserExerciseUpdateExercisesDTO(exercises, profileID, gymID, isDeleted, serverTemplateID, serverUserExerciseGroupID, userExerciseGroupName, userExerciseGroupDescription);

			string rawJSON = JsonConvert.SerializeObject(dto);

			UserExercisesUpdateExerciseResponseDTO responseObject = new UserExercisesUpdateExerciseResponseDTO();

			var uri = "UpdateUserTemplateExercises";
			try
			{
				string stringResponse = await BaseCoachServices.ServiceAPI.Post(uri, rawJSON);

				if (stringResponse == "401")
				{
					if (await TokenManager.RefreshToken())
					{
						stringResponse = await BaseCoachServices.ServiceAPI.Post(uri, rawJSON);
					}
				}
				else {
					responseObject = JsonConvert.DeserializeObject<UserExercisesUpdateExerciseResponseDTO>(stringResponse);
				}

				if (responseObject.UserWorkoutGroupID == 0)
				{
					throw new Exception("Not expected response in '" + uri + "' web service method( profileID: " + profileID.ToString() + "; + gymID: " + gymID.ToString() + ")");
				}
			}
			catch (Exception e)
			{
				Insights.Report(e);
			}
			return responseObject;
		}
Beispiel #2
0
		public static async Task<UserExercisesUpdateExerciseResponseDTO> AssignWorkoutTemplateToUser(int serverTemplateID, int profileID)
		{
			UserExercisesUpdateExerciseResponseDTO responseObject = new UserExercisesUpdateExerciseResponseDTO();

			string uri = String.Format("AssignWorkoutTemplate/{0}/ToUser/{1}", serverTemplateID, profileID);

			string response = await BaseCoachServices.ServiceAPI.Post(uri, new Newtonsoft.Json.Linq.JObject());
			if (response == "401")
			{
				if (await TokenManager.RefreshToken())
				{
					response = await BaseCoachServices.ServiceAPI.Post(uri, new Newtonsoft.Json.Linq.JObject());
				}
			}
			else {
				responseObject = JsonConvert.DeserializeObject<UserExercisesUpdateExerciseResponseDTO>(response);
			}

			if (responseObject.TemplateID != serverTemplateID)
			{
				throw new Exception("Not expected response in '" + uri + "' web service method( profileID: " + profileID.ToString() + "; + serverTemplateID: " + serverTemplateID.ToString() + ")");
			}
			return responseObject;
		}
Beispiel #3
0
		public static async Task<UserExercisesUpdateExerciseResponseDTO> UpdateUserExercises(List<UserWorkoutTemplateMapping> exercises, int gymID, int profileID, bool isDeleted, int serverUserExerciseGroupID, string userExerciseGroupName, string userExerciseGroupDescription)
		{

			var dto = UserExercisesUpdateExerciseDTOCreator.CreateUserExerciseUpdateExercisesDTO(exercises,profileID, gymID, isDeleted, 0,serverUserExerciseGroupID,userExerciseGroupName, userExerciseGroupDescription);

			string rawJSON = JsonConvert.SerializeObject(dto);

			UserExercisesUpdateExerciseResponseDTO responseObject = new UserExercisesUpdateExerciseResponseDTO ();

			var uri = "UpdateUserTemplateExercises";
			try
			{
                string stringResponse = await ExerciseService.ServiceAPI.Post(uri, rawJSON);

                if (stringResponse == "401")
                {
                    await TokenManager.RefreshToken();
                    stringResponse = await ExerciseService.ServiceAPI.Post(uri, rawJSON);
				}else{
					responseObject = JsonConvert.DeserializeObject<UserExercisesUpdateExerciseResponseDTO>(stringResponse);
				}

				if(responseObject.UserWorkoutGroupID == 0)
				{
					throw new Exception("Not expected response in '" + uri + "' web service method( profileID: " + profileID.ToString() + "; + gymID: " + gymID.ToString() + ")");
				}
			}catch(Exception e) {
				ErrorLogDAL.AddErrorLogRecord (e, DateTime.UtcNow, gymID, uri, "workoutTemplateJSON: " + rawJSON, e.Message, e.StackTrace);
			}
			return responseObject;
		}