public ActionResult Editing_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <TimesheetViewModel> timesheets) { var results = new List <TimesheetViewModel>(); if (timesheets != null && ModelState.IsValid) { foreach (var timesheet in timesheets) { _timesheetService.Create(timesheet); results.Add(timesheet); } } return(Json(results.ToDataSourceResult(request, ModelState))); }
public ActionResult <TimesheetModel> PostTimesheet(TimesheetModel timesheet) { string fileName = timesheet.employee.Substring(0, timesheet.employee.LastIndexOf(' ')) + "_" + timesheet.startPeriod.Replace("/", ".") + "_" + timesheet.endPeriod.Replace("/", "."); string outputPath = Path.Combine(hostingEnvironment.ContentRootPath, "timesheets\\" + fileName + ".pdf"); if (System.IO.File.Exists(outputPath)) { return(BadRequest("File already exists")); } else { _timesheetService.Create(timesheet); FillPdf(timesheet, outputPath); return(CreatedAtRoute( routeName: "GetTimesheet", routeValues: new { id = timesheet.Id }, value: timesheet)); } }