public async Task <IHttpActionResult> GetMediaPrintList(MediaSearchModel model) { var UserId = model.userId; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DateTime?fromDate = null, toDate = null; if ((!String.IsNullOrEmpty(model.startDate))) { fromDate = DateTime.ParseExact(model.startDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if ((!String.IsNullOrEmpty(model.endDate))) { toDate = DateTime.ParseExact(model.endDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } DateTime?dt1 = new DateTime(fromDate.Value.Year, fromDate.Value.Month, fromDate.Value.Day, 00, 00, 0); DateTime?dt2 = new DateTime(toDate.Value.Year, toDate.Value.Month, toDate.Value.Day, 23, 59, 59); var taskResult = await repository.GetMediaPrintList(UserId, fromDate, toDate, model.mediaTypeIds, HttpContext.Current.Request); return(Ok(taskResult)); }
public async Task <IHttpActionResult> ExportMediaNewsToExcel(MediaSearchModel model) { var userId = User.Identity.GetUserId <int>(); DateTime?fromDate = null, toDate = null; string pathnew = Request.RequestUri.AbsolutePath; if ((!String.IsNullOrEmpty(model.startDate))) { fromDate = DateTime.ParseExact(model.startDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if ((!String.IsNullOrEmpty(model.endDate))) { toDate = DateTime.ParseExact(model.endDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } var taskResult = repository.GeMediaListAll(userId, model.mediaTypeId, model.newsTypeIds, model.channelIds, model.categoryIds, model.sentimentIds, model.relevanceIds, model.createdBy, model.script, fromDate, toDate); var excelData = taskResult.MediaFormList; string baseUrl = ""; string excelFilename = "MediaNews" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond + ".xls"; string SaveLocation = HttpContext.Current.Request.PhysicalApplicationPath + "Files\\" + excelFilename; DataTable dt = CreateExcelFile.ListToDataTable(excelData); CreateExcelFile file = new CreateExcelFile(); string detail = file.CreateExcelSheet(dt, SaveLocation, new List <int>(), new List <int>(), new List <string>()); baseUrl = "Files/" + excelFilename; return(Ok(baseUrl)); }
private async Task LoadSavedSearchModel(MediaSearchModel searchModel) { var c = (IConfigurable)searchModel; var cs = await _engine.LoadSettings(c.SettingName); if (!string.IsNullOrEmpty(cs)) { c.DeserializeSettings(cs); } }
public async Task <IHttpActionResult> GetMediaFormsList(MediaSearchModel model) { var userId = User.Identity.GetUserId <int>(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DateTime?fromDate = null, toDate = null; if ((!String.IsNullOrEmpty(model.startDate))) { fromDate = DateTime.ParseExact(model.startDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if ((!String.IsNullOrEmpty(model.endDate))) { toDate = DateTime.ParseExact(model.endDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } var taskResult = await repository.GeMediaList(userId, model.mediaTypeId, model.newsTypeIds, model.channelIds, model.categoryIds, model.sentimentIds, model.relevanceIds, model.createdBy, model.script, model.getOptions, fromDate, toDate, model.pageNumber); return(Ok(taskResult)); }
private Task SaveSearchModel(MediaSearchModel searchModel) { var c = (IConfigurable)searchModel; return(_engine.SaveSettings(c.SettingName, c.SerializeSettings())); }