/// <summary> /// Updates one practice entry /// </summary> /// <param name="id">practice id</param> /// <param name="model">practice data</param> /// <returns></returns> public async Task UpdatePracticeAsync(int id, PracticeModel model) { await PutAsJsonAsync(model, "api/practice/" + id); }
/// <summary> /// Legt eine Übung am Server an /// </summary> /// <param name="scheduleId"></param> /// <param name="exerciseId"></param> /// <param name="timestamp"></param> /// <param name="weight"></param> /// <param name="repetitions"></param> /// <param name="numberOfRepetitions"></param> /// <returns></returns> public async Task<int> recordPractice(int scheduleId, int exerciseId, string userId, DateTime timestamp = default(DateTime), double weight = 0, int repetitions = 0, int numberOfRepetitions = 0, string username = "", string password = "") { try { PracticeModel practice = new PracticeModel(); practice.ScheduleId = scheduleId; practice.ExerciseId = exerciseId; practice.UserId = userId; practice.Timestamp = timestamp; practice.Weight = weight; practice.Repetitions = repetitions; practice.NumberOfRepetitions = numberOfRepetitions; if(session == null) { session = await getSession(username, password); } PracticeModel result = await session.Users.CreatePracticeAsync(practice); if (result.Id != 0) return result.Id; else return 0; } catch (ServerException ex) { throw; } catch (Exception exc) { Console.WriteLine("Fehler beim Eintragen eines Trainings: " + exc.StackTrace); } return 0; }
/// <summary> /// Creates an new Practice /// </summary> /// <param name="model">practice data</param> /// <returns></returns> public async Task<PracticeModel> CreatePracticeAsync(PracticeModel model) { return await this.PostAsJsonReturnAsync<PracticeModel, PracticeModel>(model, "api/practice"); }