/// <summary>
        /// Edit Api
        /// </summary>
        /// <param name="id"></param>
        /// <param name="trainingdetails"></param>
        /// <returns></returns>

        public HttpResponseMessage Put(int id, [FromBody] TrainingDetail trainingdetails)
        {
            try
            {
                using (AdventureWorks2014Entities2 entities = new AdventureWorks2014Entities2())
                {
                    var entity = entities.TrainingDetails.FirstOrDefault(e => e.id == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee with Id = " + id.ToString() + "NotFound to update"));
                    }
                    else
                    {
                        entity.Name      = trainingdetails.Name;
                        entity.StartDate = trainingdetails.StartDate;
                        entity.EndDate   = trainingdetails.EndDate;
                        entities.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public void AndDateIsNull_ThenExpiredShouldBeFalse()
        {
            var detail = new TrainingDetail {
                EffectiveTo = null
            };

            detail.HasExpired.Should().BeFalse();
        }
        public void AndDateIsToday_ThenExpiredShouldBeTrue()
        {
            var detail = new TrainingDetail {
                EffectiveTo = DateTime.Today
            };

            detail.HasExpired.Should().BeFalse();
        }
예제 #4
0
        //async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        //{
        //    var item = args.SelectedItem as Item;
        //    if (item == null)
        //        return;

        //    await Navigation.PushAsync(new ExDetailPage(new ItemDetailViewModel(item)));

        //    // Manually deselect item.
        //    ItemsListView.SelectedItem = null;
        //}

        async void AddItem_Clicked(object sender, EventArgs e)
        {
            var lastTraining = await App.Database.GetLastTrainingABAsync();

            if (lastTraining == null)
            {
                lastTraining = new TrainingDetail();
            }
            await Navigation.PushModalAsync(new NavigationPage(new AddTrainingPage(lastTraining)));
        }
예제 #5
0
 public Task <int> SaveTrainingAsync(TrainingDetail item)
 {
     if (item.ID == null)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertAsync(item));
     }
 }
        /// <summary>
        /// Post Api
        /// </summary>
        /// <param name="trainingdetails"></param>
        /// <returns></returns>

        public HttpResponseMessage Post([FromBody] TrainingDetail trainingdetails)
        {
            try
            {
                HttpResponseMessage message = null;
                using (AdventureWorks2014Entities2 entities = new AdventureWorks2014Entities2())
                {
                    if (entities != null)
                    {
                        entities.TrainingDetails.Add(trainingdetails);
                        entities.SaveChanges();
                        message = Request.CreateResponse(HttpStatusCode.Created, trainingdetails);
                        message.Headers.Location = new Uri(Request.RequestUri + @"\" + trainingdetails.id.ToString());
                    }

                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadGateway, ex));
            }
        }
예제 #7
0
        private static bool IsValidFrameworkCode(TrainingDetail framework, string frameworkCode)
        {
            var code = framework.TrainingCode.Split('-').FirstOrDefault();

            return(!String.IsNullOrEmpty(code) && code.Equals(frameworkCode) && !framework.HasExpired);
        }
예제 #8
0
        TrainingDetail CreateViewModel(TrainingDetail estimatedTraining)
        {
            return(new TrainingDetail
            {
                ID = Guid.NewGuid(),
                Date = DateTime.Now,
                TrainingA = estimatedTraining.TrainingA,
                Done = estimatedTraining.Done,
                Comment = estimatedTraining.Comment,
                //Exercises
                SquatsKG = estimatedTraining.SquatsKG + 5,
                SquatsS = estimatedTraining.SquatsS,
                SquatsQ = estimatedTraining.SquatsQ,

                DeadlifKG = estimatedTraining.DeadlifKG + 5,
                DeadliftS = estimatedTraining.DeadliftS,
                DeadliftQ = estimatedTraining.DeadliftQ,
                //wyciskanie leżąc
                BarbellPressKG = estimatedTraining.BarbellPressKG + 2.5,
                BarbellPressS = estimatedTraining.BarbellPressS,
                BarbellPressQ = estimatedTraining.BarbellPressQ,
                //zołnierskie
                OHPKG = estimatedTraining.OHPKG + 2.5,
                OHPS = estimatedTraining.OHPS,
                OHPQ = estimatedTraining.OHPQ,
                //Wiosłowanie
                BORKG = estimatedTraining.BORKG + 2.5,
                BORS = estimatedTraining.BORS,
                BORQ = estimatedTraining.BORQ,
                //waskie podciaganie
                CChinUpKG = estimatedTraining.CChinUpKG + 2.5,
                CChinUpS = estimatedTraining.CChinUpS,
                CChinUpQ = estimatedTraining.CChinUpQ,

                //barki bokiem
                DLRKG = estimatedTraining.DLRKG + 2.5,
                DLRS = estimatedTraining.DLRS,
                DLRQ = estimatedTraining.DLRQ,

                CBarbellPressKG = estimatedTraining.CBarbellPressKG + 2.5,
                CBarbellPressS = estimatedTraining.CBarbellPressS,
                CBarbellPressQ = estimatedTraining.CBarbellPressQ,

                BicTricKG = estimatedTraining.BicTricKG + 2.5,
                BicTricS = estimatedTraining.BicTricS,
                BicTricQ = estimatedTraining.BicTricQ,

                BicKG = estimatedTraining.BicKG + 2.5,
                BicS = estimatedTraining.BicS,
                BicQ = estimatedTraining.BicQ,

                AllahsKG = estimatedTraining.AllahsKG + 2.5,
                AllahsS = estimatedTraining.AllahsS,
                AllahsQ = estimatedTraining.AllahsQ,


                PlankSeconds = estimatedTraining.PlankSeconds,
                PlankS = estimatedTraining.PlankS,

                CalfKG = estimatedTraining.CalfKG + 2.5,
                CalfS = estimatedTraining.CalfS,
                CalfQ = estimatedTraining.CalfQ,
            });
        }
예제 #9
0
 public AddTrainingPage(TrainingDetail lastTraining)
 {
     InitializeComponent();
     BindingContext = viewModel = CreateViewModel(lastTraining);
 }
예제 #10
0
 public Task <int> DeleteTrainingAsync(TrainingDetail item)
 {
     return(database.DeleteAsync(item));
 }
예제 #11
0
 public virtual TrainingDetail Put(TrainingDetail trainingDetail)
 {
     _trainingCommands.ActiveUser = Models.ApiContext.ActiveUser;
     return(_trainingCommands.Put(trainingDetail));
 }