public static void CopyFromEntity(GetBannerResponse response, PromoBanner promo) { response.banner_id = promo.BannerID; response.caption = promo.Caption; response.image_name = ImagePathService.bannersImagePath + promo.BannerImage; response.category = promo.Category; response.status_id = promo.StatusId ? 1 : 0; }
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); }
public NegotiatedContentResult <GetBannerResponse> GetBanner([FromBody] GetBannerRequest request) { GetBannerResponse resp = _promoServices.GetBanner(request); return(Content(HttpStatusCode.OK, resp)); }