public ActionResult StatementRestDays(string sid, DateTime? dateStart, int? daysCount, string cause) { var data = new StatementRestFewDays(); data.SidEmployee = sid; data.DateStart = dateStart.Value; data.DaysCount = daysCount.Value; data.Cause = cause; data.Configure(); return View("Statement", data); }
public ActionResult StatementRestFewDays(StatementRestFewDays data) { try { data.Configure(); } catch (Exception ex) { TempData["ServerError"] = ex.Message; return View("StatementFewDays", data); } HtmlToPdf converter = new HtmlToPdf(); string url = Url.Action("StatementRestDays", new{sid=data.SidEmployee, dateStart=data.DateStart, daysCount=data.DaysCount, cause=data.Cause}); var leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port); url = String.Format("{1}{0}", url, leftPartUrl); PdfDocument doc = converter.ConvertUrl(url); MemoryStream stream = new MemoryStream(); doc.Save(stream); return File(stream.ToArray(), "application/pdf"); }
public ActionResult StatementRestFewDays(StatementRestFewDays data) { try { data.Configure(); } catch (Exception ex) { TempData["ServerError"] = ex.Message; return View("StatementFewDays", data); } HtmlToPdf converter = new HtmlToPdf(); var statementPrint = new StatementPrint { IdStatementType = 2, EmployeeSid = data.SidEmployee, DateBegin = data.DateStart, DateEnd = data.DateStart.AddDays(data.DaysCount), DurationDays = data.DaysCount, Cause = data.Cause, IdDepartment = data.Employee.Department.Id, IdOrganization = data.Employee.Organization.Id, Confirmed = false }; ResponseMessage rm; if (statementPrint.Save(out rm)) statementPrint.Id = rm.Id; string url = Url.Action("StatementRestDays", new{sid=data.SidEmployee, dateStart=data.DateStart, daysCount=data.DaysCount, cause=data.Cause, id=statementPrint.Id}); var leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port); url = String.Format("{1}{0}", url, leftPartUrl); PdfDocument doc = converter.ConvertUrl(url); MemoryStream stream = new MemoryStream(); doc.Save(stream); return File(stream.ToArray(), "application/pdf"); }