Example #1
0
 // 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);
            };
        }
Example #3
0
 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);
     }
 }
Example #4
0
        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);
        }
Example #5
0
 // POST: api/Training
 public int Post([FromBody] TrainingEntity TrainingEntity)
 {
     return(_TrainingServices.CreateTraining(TrainingEntity));
 }
Example #6
0
 /// <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);
 }