public WorkoutResultJsonModel AddWorkout(WorkoutJsonModel model) { DateTime start, end; start = DateTime.ParseExact(model.Start, "yyyy-MM-dd HH:mm:ss", null); end = DateTime.ParseExact(model.End, "yyyy-MM-dd HH:mm:ss", null); Workout workout = new Workout { Created = DateTime.Now, LastModified = DateTime.Now, Distance = model.Distance, Duration = model.Duration, End = end, Start = start, Type = model.Type, IsDeleted = false, User_Id = model.UserId }; workout = _workoutRepository.AddWorkout(workout); return new WorkoutResultJsonModel() {WorkoutId = workout.Id}; }
/// <summary> /// Create a new Workout object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="start">Initial value of the Start property.</param> /// <param name="end">Initial value of the End property.</param> /// <param name="created">Initial value of the Created property.</param> /// <param name="lastModified">Initial value of the LastModified property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> /// <param name="user_Id">Initial value of the User_Id property.</param> /// <param name="type">Initial value of the Type property.</param> /// <param name="duration">Initial value of the Duration property.</param> public static Workout CreateWorkout(global::System.Int32 id, global::System.DateTime start, global::System.DateTime end, global::System.DateTime created, global::System.DateTime lastModified, global::System.Boolean isDeleted, global::System.Int32 user_Id, global::System.Int32 type, global::System.Int32 duration) { Workout workout = new Workout(); workout.Id = id; workout.Start = start; workout.End = end; workout.Created = created; workout.LastModified = lastModified; workout.IsDeleted = isDeleted; workout.User_Id = user_Id; workout.Type = type; workout.Duration = duration; return workout; }
/// <summary> /// Deprecated Method for adding a new object to the Workouts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToWorkouts(Workout workout) { base.AddObject("Workouts", workout); }