Esempio n. 1
0
        public GymDayServiceResponse CreateGymDay(GymDay newGymDay)
        {
            var result = new GymDayServiceResponse();

            try
            {
                if (!IsThereAGymDayForToday())
                {
                    newGymDay.LastDone = DateTime.Now;
                    _repo.Insert(newGymDay);
                    result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateSuccess;
                    result.ListOfGymDays.Add(newGymDay);
                }

                result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateFail;
            }
            catch (Exception e)
            {
                result.Exception = e;
                result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateFail;
            }

            return result;
        }
Esempio n. 2
0
        internal GymDayServiceResponse UpdateGymDay(GymDay newSet)
        {
            var result = new GymDayServiceResponse();

            try
            {
                // This operation returns a boolean, not sure how to leverage it.
                var workoutToUpdate = _repo.GetById(newSet.Id);
                workoutToUpdate.LastDone = newSet.LastDone;
                workoutToUpdate.Name = newSet.Name;

                workoutToUpdate.WorkoutsForDay = newSet.WorkoutsForDay;
                _repo.Update(workoutToUpdate);
                result.ServiceResponseCode = GymDaysServiceResponseCodes.UpdateSuccess;

                result.ListOfGymDays = new List<GymDay>() {workoutToUpdate};
            }
            catch (Exception e)
            {
                result.Exception = e;
                result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateFail;
            }

            return result;
        }
Esempio n. 3
0
 public GymDayServiceResponse CreateGymDay(GymDay newSet)
 {
     return _gymDayService.CreateGymDay(newSet);
 }
Esempio n. 4
0
 public GymDayServiceResponse AddSetToGymDay(GymDay newSet)
 {
     return _gymDayService.UpdateGymDay(newSet);
 }