public InfoBannerResponse GetInfoBanner(GetInfoBannerRequest request) { InfoBannerResponse response = new InfoBannerResponse(); 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> bList = dao.GetInfoBanners(); if (bList.Count <= 0) { response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("promo.info.not.found"); return(response); } InfoBannerDto[] promoDtos = new InfoBannerDto[bList.Count()]; for (int i = 0; i < bList.Count; i++) { InfoBannerDto dto = new InfoBannerDto(); PromoHelper.CopyFromEntity(dto, bList[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 GetBannerResponse GetBanner(GetBannerRequest request) { GetBannerResponse response = new GetBannerResponse(); 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()) { GetBannerResponse dto = new GetBannerResponse(); PromoBanner promo = dao.FindByCategoty(request.category); if (promo == null) { response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("promo.banner.not.found"); return(response); } if (promo != null) { PromoHelper.CopyFromEntity(dto, promo); } response = dto; response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("promo.banner.found"); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }