public async Task <IEnumerable <Responder> > Get() { string nowRespondingSortExpression = string.Empty; // TODO get subscriberId from context IEnumerable <Responder> responders = await UnitOfWork.ResponderRepository.GetRespondersBySubscriberId(ApplicationContext.CurrentUser.SubscriberId); // TODO get user type from context (int)Context.CurrentUser.User.UserType MemberPreferences preference = await UnitOfWork.MemberPreferencesRepository.GetPreferencesByMemberIdAsync(ApplicationContext.CurrentUser.MemberId, (int)ApplicationContext.CurrentUser.UserType); if (preference != null) { nowRespondingSortExpression = (preference.NowRespondingSort ?? string.Empty); // this is a temporary for a confusion in the ios client, // we simply reverse the sorts for date/time fields nowRespondingSortExpression = nowRespondingSortExpression.Contains("callingtime asc") ? nowRespondingSortExpression.Replace("callingtime asc", "callingtime desc") : nowRespondingSortExpression.Replace("callingtime desc", "callingtime asc"); nowRespondingSortExpression = nowRespondingSortExpression.Contains("eta asc") ? nowRespondingSortExpression.Replace("eta asc", "eta desc") : nowRespondingSortExpression.Replace("eta desc", "eta asc"); } return(Responder.ForResponse(responders, nowRespondingSortExpression)); }
public async Task <List <OnDuties> > Get() { List <OnDuties> onDutiesList = new List <OnDuties>(); int memberid = ApplicationContext.CurrentUser.MemberId; int userType = (int)ApplicationContext.CurrentUser.UserType; long agencyid = (long)ApplicationContext.CurrentUser.SubscriberId; onDutiesList = await UnitOfWork.OnDutiesRepository.GetOnScheduleOnAsync(agencyid); MemberPreferences memberPreferences = await UnitOfWork.MemberPreferencesRepository.GetPreferencesByMemberIdAsync(memberid, userType); string onDutySortExpression = memberPreferences == null ? string.Empty : (memberPreferences.OnScheduleSort ?? string.Empty); onDutiesList = OnDuties.ForResponse(onDutiesList, onDutySortExpression); return(onDutiesList); }
private void GetAll() { mapper = new AutoMapperTest(); mapper.Reset(); mapper.IsValidConfiguration(); List <OnDuties> list = new List <OnDuties>(); MemberPreferences mp = new MemberPreferences(); var genericIdentity = new API.Authorization.User("4", true, "dummyUser", API.Authorization.User.IarUserTypes.User, "", "", DateTime.Now, 125625, 168); _mockUW.Setup(m => m.OnDutiesRepository.GetOnScheduleOnAsync(genericIdentity.SubscriberId)).ReturnsAsync(list); _mockUW.Setup(m => m.MemberPreferencesRepository.GetPreferencesByMemberIdAsync(genericIdentity.MemberId, (int)genericIdentity.UserType)).ReturnsAsync(mp); _controller = new OnDutiesController(_mockUW.Object, new ApplicationContext(genericIdentity)); var result = _controller.Get(); Assert.NotNull(result); }