/// <summary> /// Get AttendeeHour view model by Id. /// </summary> /// <param name="id"></param> /// <returns></returns> public AttendeeHourViewModel Get(int id) { var attendeeHourViewModel = new AttendeeHourViewModel(); var attendeeHour = _attendeeHourRepo.Get(id); if (attendeeHour != null) { attendeeHourViewModel = _mapper.Map <AttendeeHourViewModel>(attendeeHour); } return(attendeeHourViewModel); }
public AttendeeHourViewModel GetByAttendeeAndWorkshop(int attendeeId, int workshopId) { var attendeeHourViewModel = new AttendeeHourViewModel(); var attendeeHour = _attendeeHourRepo.GetByAttendeeAndWorkshop(attendeeId, workshopId); if (attendeeHour != null) { attendeeHourViewModel = _mapper.Map <AttendeeHourViewModel>(attendeeHour); } return(attendeeHourViewModel); }
/// <summary> /// Adds a new attendee hour if Id is zero or updates it. /// </summary> /// <param name="attendeeHourEditModel"></param> public AttendeeHourViewModel AddOrUpdate(AttendeeHourEditModel attendeeHourEditModel) { var attendeeHourViewModel = new AttendeeHourViewModel(); attendeeHourViewModel.Id = attendeeHourEditModel.Id; attendeeHourViewModel.AttendeeId = attendeeHourEditModel.AttendeeId; attendeeHourViewModel.WorkshopId = attendeeHourEditModel.WorkshopId; attendeeHourViewModel.Comments = attendeeHourEditModel.Comments; var attendeeHour = _mapper.Map <AttendeeHour>(attendeeHourEditModel); if (attendeeHour.Id == 0) { attendeeHour = _attendeeHourRepo.Add(attendeeHour); attendeeHourViewModel = _mapper.Map <AttendeeHourViewModel>(attendeeHour); } else { _attendeeHourRepo.Update(attendeeHour); } return(attendeeHourViewModel); }