// PUT: api/Training/5 public bool Put(int id, [FromBody] TrainingEntity TrainingEntity) { if (id > 0) { return(_TrainingServices.UpdateTraining(id, TrainingEntity)); } return(false); }
public override void ViewDidLoad() { base.ViewDidLoad(); btnSaveItem.TouchUpInside += (sender, e) => { var item = new TrainingEntity { Text = txtTitle.Text, Description = txtDesc.Text }; ViewModel.AddItemCommand.Execute(item); NavigationController.PopToRootViewController(true); }; }
public int CreateTraining(TrainingEntity trainingEntity) { using (var scope = new TransactionScope()) { var training = new Training() { trainingId = trainingEntity.trainingId, name = trainingEntity.name, description = trainingEntity.description }; _unitOfWork.TrainingRepository.Insert(training); _unitOfWork.Save(); scope.Complete(); return(training.trainingId); } }
public bool UpdateTraining(int trainingId, TrainingEntity trainingEntity) { var success = false; if (trainingEntity != null) { using (var scope = new TransactionScope()) { var training = _unitOfWork.TrainingRepository.GetByID(trainingId); if (training != null) { training.name = trainingEntity.name; training.description = trainingEntity.description; _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
// POST: api/Training public int Post([FromBody] TrainingEntity TrainingEntity) { return(_TrainingServices.CreateTraining(TrainingEntity)); }
/// <summary> /// Adds the training to the database /// </summary> /// <param name="trainingEntity">The training entity.</param> /// <returns>The boolean result true or false if training is inserted.</returns> public bool AddTraining(TrainingEntity trainingEntity) { _task3DbContext.Add(trainingEntity); return((_task3DbContext.SaveChanges() > 0) ? true : false); }