public static ReportKeyValueListResponseFloatDto GetSuperUserSellerReportDelivered(SuperUserReportSellerDeliveredRequest request) { ReportKeyValueListResponseFloatDto response = new ReportKeyValueListResponseFloatDto(); try { if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response)) { response.message = MessagesSource.GetMessage("invalid.super.user"); return(response); } SellerReportDeliveredRequest req = new SellerReportDeliveredRequest { entity_id = request.agency_id, periodical_data = request.periodical_data, for_role = UserType.SuperUser }; return(ReportsServices.GetSellerReportSellerReportDelivered(req)); } catch (Exception e) { response.MakeExceptionResponse(e); return(response); } }
//Reports Delivered for AgentBoss private static List <ReportKeyValuePairDoubleDto> GetAgentBossReportDataDeliveredWeekly(SellerReportDeliveredRequest request) { List <ReportKeyValuePairDoubleDto> resp = new List <ReportKeyValuePairDoubleDto>(); Random random = new Random(); for (int i = 0; i < 4; i++) { resp.Add(new ReportKeyValuePairDoubleDto() { key = "Week " + (i + 1), value = random.NextDouble() * 100.0 }); } return(resp); }
private static List <ReportKeyValuePairDoubleDto> GetAgentBossReportDataDeliveredMonthly(SellerReportDeliveredRequest request) { List <ReportKeyValuePairDoubleDto> resp = new List <ReportKeyValuePairDoubleDto>(); List <String> lastFourMonth = GetLastMonths(4); Random random = new Random(); for (int i = 0; i < 4; i++) { resp.Add(new ReportKeyValuePairDoubleDto() { key = lastFourMonth[i], value = random.NextDouble() * 100.0 }); } return(resp); }
//Common methods public static ReportKeyValueListResponseFloatDto GetSellerReportSellerReportDelivered(SellerReportDeliveredRequest request) { ReportKeyValueListResponseFloatDto resp = new ReportKeyValueListResponseFloatDto { //TODO Implement report = new List <ReportKeyValuePairDoubleDto>() }; switch (request.for_role) { case UserType.SuperUser: resp.code = 1; resp.has_resource = 1; resp.httpCode = System.Net.HttpStatusCode.OK; switch (request.periodical_data) { case 1: //Month resp.report.AddRange(GetSuperUserReportDataDeliveredMonthly(request)); break; case 2: //Week resp.report.AddRange(GetSuperUserReportDataDeliveredWeekly(request)); break; default: resp.message = "Wrong period. Only accept 1 for Month and 2 for Week" + request.periodical_data; resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; } break; case UserType.AgentBoss: resp.code = 1; resp.has_resource = 1; resp.httpCode = System.Net.HttpStatusCode.OK; switch (request.periodical_data) { case 1: //Month resp.report.AddRange(GetAgentBossReportDataDeliveredMonthly(request)); break; case 2: //Week resp.report.AddRange(GetAgentBossReportDataDeliveredWeekly(request)); break; default: resp.message = "Wrong period. Only accept 1 for Month and 2 for Week" + request.periodical_data; resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; } break; case UserType.AgentAdmin: resp.message = "Wrong role " + request.for_role.ToCleanString(); resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; case UserType.Driver: resp.message = "Wrong role " + request.for_role.ToCleanString(); resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; case UserType.Consumer: resp.message = "Wrong role " + request.for_role.ToCleanString(); resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; default: resp.message = "Wrong role " + request.for_role.ToCleanString(); resp.code = 0; resp.has_resource = 0; resp.httpCode = System.Net.HttpStatusCode.BadRequest; break; } return(resp); }