public async Task <ActionResult> Export(CloseShopViewModel Filter) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")); DateTime dateTo = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")); string exec = $"sp_PDC_Dashboard_CloseShopCoverPage_Get '{dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{dateTo.ToString("yyyyMMdd", new CultureInfo("en-US"))}', '{UserData.Username}', '{Filter.BranchList}'"; _logger.LogInformation(exec); List <EOD> edo = await DB.EOD.FromSql(exec).ToListAsync(); if (edo.Count() <= 0) { Response.Success = false; Response.Errors.Add(new { Key = "BranchId", Message = "No data found for " + Filter.BranchList }); HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(Response.Render())); } return(Filter.FileType.Equals("excel") ? this.ExportExcel(edo, dateFrom) : this.ExportPDF(edo)); }
public async Task <ActionResult> Get(CloseShopViewModel Filter, string Type, string FileType) { if (!ModelState.IsValid) { return(Json(Response.RenderError(ModelState))); } // Parameter Type = Type ?? string.Empty; FileType = FileType ?? string.Empty; Pagination pagination = new Pagination(HttpContext); // Auth Data var userData = User.Claims.SingleOrDefault(c => c.Type.Equals("User")).Value; UserMapRole UserData = JsonConvert.DeserializeObject <UserMapRole>(userData); DateTime dateFrom = DateTime.ParseExact(Filter.DateFrom, "dd/MM/yyyy", new CultureInfo("en-US")); string parameter = "'" + dateFrom.ToString("yyyyMMdd", new CultureInfo("en-US")) + "', '" + UserData.Username + "', '" + Filter.BranchList + "'"; int count = 0; int totalCount = 0; object result = new List <object>(); string EXEC = "EXEC sp_PDC_Dashboard_CloseShop_Get "; if (Type.Equals("confirm")) { //EXEC = "EXEC sp_RPT302_DailyRevenueConfirmed "; } string sql = EXEC + parameter; _logger.LogInformation(sql); if (Type.Equals("closeshop")) { IQueryable <CloseShop> CloseShop = DB.CloseShop.FromSql(sql); if (FileType.Equals("excel")) { //return await ExportExcelVerify(DailyRevenue); } count = await CloseShop.Skip(pagination.From()).Take(pagination.To()).CountAsync(); totalCount = CloseShop.Count(); result = await CloseShop.Skip(pagination.From()).Take(pagination.To()).ToListAsync(); } //else if (type.Equals("confirm")) //{ // IQueryable<DailyRevenueConfirm> DailyRevenue = DB.DailyRevenueConfirm.FromSql(EXEC + parameter); // if (filetype.Equals("excel")) // { // //return await ExportExcelConfirm(DailyRevenue); // } // count = await DailyRevenue.Skip(pagination.From()).Take(pagination.To()).CountAsync(); // totalCount = DailyRevenue.Count(); // result = await DailyRevenue.Skip(pagination.From()).Take(pagination.To()).ToListAsync(); //} Response.Success = true; Response.Result = result; Response.ResultInfo = new { page = pagination.Page, perPage = pagination.PerPage, count, totalCount }; DB.Dispose(); return(Json(Response.Render())); }