public HttpResponseMessage Update(TrainingProgram dto) { var repo = new TrainingRepository(); var dbResult = repo.Update(dto); return(Request.CreateUpdateRecordResponse(dbResult)); }
public void UpdateDistance() { Console.WriteLine("Enter Training id:"); string trainingId = Console.ReadLine(); int tryint; while (!int.TryParse(trainingId, out tryint)) { Console.WriteLine("Incorrect id! Try again "); trainingId = Console.ReadLine(); } Console.Write("Enter new distance:"); string newDistance = Console.ReadLine(); while ((!int.TryParse(newDistance, out tryint)) || (!DistanceValidationAttribute.IsValidDistance(Convert.ToInt32(newDistance)))) { Console.WriteLine("Incorrect distance! Try again "); newDistance = Console.ReadLine(); } try { Training training = new Training { Distance = Convert.ToInt32(newDistance) }; using (swimmingContext swimdb = new swimmingContext()) { ITrainingManager <Training> trainingManager = new TrainingRepository(swimdb); trainingManager.Update(Convert.ToInt32(trainingId), training); Console.WriteLine("Distance is updated"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public IActionResult Put([FromBody] Training item) { _repository.Update(item); return(Ok()); }
public void Put(int id, [FromBody] Training item) { _repository.Update(item); }