public GymDayServiceResponse GetWod() { var result = new GymDayServiceResponse(); try { // This operation returns a boolean, not sure how to leverage it. var listOfDays = _repo.GetAll(); foreach (var day in listOfDays) { if (day.LastDone.Date == DateTime.Today.Date) { listOfDays = new List<GymDay>(); listOfDays.Add(day); break; } } result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateSuccess; result.ListOfGymDays = listOfDays as List<GymDay>; } catch (Exception e) { result.Exception = e; result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateFail; } return result; }
public GymDayServiceResponse GetGymDays() { var result = new GymDayServiceResponse(); try { // This operation returns a boolean, not sure how to leverage it. var listOfDays = _repo.GetAll(); result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateSuccess; result.ListOfGymDays = listOfDays as List<GymDay>; } catch (Exception e) { result.Exception = e; result.ServiceResponseCode = GymDaysServiceResponseCodes.CreateFail; } return result; }
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; }
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; }