/// <summary> /// Bind data from explanation detail to view model /// </summary> /// <param name="id">id of explanation</param> /// <returns> ExplanationRequestViewModel </returns> public ExplanationRequestViewModel GetExplanationDetailViewModel(int id) { List <ExplanationRequestViewModel> listModel = new List <ExplanationRequestViewModel>(); // get explanation single var model = _explanationRequestService.GetExplanationDetail(id); // bind data to view model ExplanationRequestViewModel modelView = new ExplanationRequestViewModel { ID = model.ID, Title = model.Title, Actual = model.Actual, GroupName = model.AppUserCreatedBy.Group.Name, FullNameDelegate = AppUserManager.Users.Where(x => x.Id.Equals(model.DelegateId)).FirstOrDefault() != null?AppUserManager.Users.Where(x => x.Id.Equals(model.DelegateId)).FirstOrDefault().FullName : null, User = new AppUserViewModel { Id = model.AppUserCreatedBy.Id, FullName = model.AppUserCreatedBy.FullName, Group = model.FingerTimeSheet.FingerMachineUsers.AppUser.Group.Name != null ? new GroupViewModel { Name = model.FingerTimeSheet.FingerMachineUsers.AppUser.Group.Name } : new GroupViewModel { } }, Receiver = new AppUserViewModel { Id = model.Receiver.Id, FullName = model.Receiver.FullName }, ReasonDetail = model.ReasonDetail, CreatedDate = (DateTime)model.CreatedDate, CreatedBy = model.CreatedBy, FullName = model.AppUserCreatedBy.FullName, ExplanationDate = model.FingerTimeSheet.DayOfCheck, StatusRequest = new StatusRequestViewModel { ID = model.StatusRequest.ID, Name = model.StatusRequest.Name }, Approver = model.UpdatedBy != null ? new AppUserViewModel { Id = model.AppUserUpdatedBy.Id, FullName = model.AppUserUpdatedBy.FullName } : new AppUserViewModel { }, AbnormalReason = _explanationRequestService.GetAbnormalById(model.TimeSheetId).Select(m => new AbnormalCaseReasonViewModel { ReasonId = m.AbnormalReason.ID, ReasonName = m.AbnormalReason.Name }).ToList() }; // convert reason name in list to string ConvertSubstringToString(modelView); return(modelView); }
public void ExplanationDetailTest1() { var explanation = explanationService.GetExplanationDetail(1); Assert.IsNotNull(explanation); }