public static void CopyToEntity(PromoInfo promo, GetInfoBannerListRequest request) { // auth_token, page_number, records_per_page }
public GetInfoBannerListResponse GetInfoBannerList(GetInfoBannerListRequest request) { GetInfoBannerListResponse response = new GetInfoBannerListResponse(); try { switch (request.user_type) { case (int)UserType.SuperUser: if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response)) { response.message = MessagesSource.GetMessage("invalid.super.user"); return(response); } break; case (int)UserType.AgentBoss: if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { return(response); } break; case (int)UserType.AgentAdmin: if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response)) { return(response); } break; case (int)UserType.Driver: if (!DriverServices.CheckAuthDriver(request.user_id, request.auth_token)) { _userServices.MakeNouserResponse(response); return(response); } break; case (int)UserType.Consumer: if (!_userServices.CheckAuthUser(request.user_id, request.auth_token)) { _userServices.MakeNouserResponse(response); return(response); } break; default: { response.has_resource = 0; response.code = 1; response.message = MessagesSource.GetMessage("invalid.user.type"); return(response); } } using (PromoDao dao = new PromoDao()) { List <PromoInfo> pList = dao.GetInfoBannerList(request.page_number, request.records_per_page); if (pList.Count <= 0) { response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("promo.info.not.found"); return(response); } InfoBannerListDto[] promoDtos = new InfoBannerListDto[pList.Count()]; for (int i = 0; i < pList.Count; i++) { InfoBannerListDto dto = new InfoBannerListDto(); PromoHelper.CopyFromEntity(dto, pList[i]); promoDtos[i] = dto; } response.info_banners = promoDtos; response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("promo.info.found"); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public NegotiatedContentResult <GetInfoBannerListResponse> GetInfoBannerList([FromBody] GetInfoBannerListRequest request) { GetInfoBannerListResponse resp = _promoServices.GetInfoBannerList(request); return(Content(HttpStatusCode.OK, resp)); }