public IActionResult DeleteEnvelope(int id) { //doe hier de delete var envelope = _envelopeRepository.GetEnvelopeById(id); _envelopeRepository.Delete(envelope); _envelopeRepository.Save(); return(RedirectToAction("EnvelopeManagement")); }
public IActionResult PrintAddresses(string klantId, int envelopeId) { var envelope = _mapper.Map <EnvelopeViewModel>(_envelopeRepository.GetEnvelopeById(envelopeId)); var addresses = _mapper.Map <List <AddressViewModel> >(_addressRepository.GetAddressesByKlantId(klantId)); if (addresses.Any()) { // Create new PDF document _document = CreatePdf(); foreach (var address in addresses) { // Create new page var page = CreatePdfPage(envelope.Breedte, envelope.Lengte); //document.AddPage(); // Create address CreateAddress(page, address, envelope); } //(var i = 0; i < addresses.Count; i++) //{ // // Create new page // var page = CreatePdfPage(document); //document.AddPage(); // //page.Size = PageSize.A5; // //page.Orientation = PageOrientation.Landscape; // //page.Width = XUnit.FromMillimeter(170); // //page.Height = XUnit.FromMillimeter(170); // // Create address // XGraphics gfx = XGraphics.FromPdfPage(page); // gfx.RotateAtTransform(270,new XPoint(170,270)); // // Create a font // XFont font = new XFont("Times New Roman", 16, XFontStyle.Regular); // //get address for test // var address = _addressRepository.GetAddressById(i + 6); // var naam = string.Concat(address.Voornaam, address.Tussenvoegsel != null ? " " + address.Tussenvoegsel : " ", address.Achternaan); // // Draw the text // gfx.DrawString(string.Concat(address.Voornaam, address.Tussenvoegsel != null ? " " + address.Tussenvoegsel + " " : " ", address.Achternaan), font, XBrushes.Black, new XRect(100, 40, page.Width, page.Height), XStringFormats.CenterLeft); // gfx.DrawString(string.Concat(address.Straat, " ", address.Huisnummer, " ", address.HuisnummerToevoeging), font, XBrushes.Black, new XRect(100, 60, page.Width, page.Height), XStringFormats.CenterLeft); // gfx.DrawString(string.Concat(address.Postcode, " ", address.Plaats), font, XBrushes.Black, new XRect(100, 80, page.Width, page.Height), XStringFormats.CenterLeft); // if (address.LandId != Constants.DefaultCountryNlId) // { // gfx.DrawString(string.Concat(_countryRepository.GetById(address.LandId)), font, XBrushes.Black, new XRect(100, 100, page.Width, page.Height), XStringFormats.CenterLeft); // } //} // Send PDF to browser var stream = new MemoryStream(); _document.Save(stream, false); Response.Clear(); Response.ContentType = "application/pdf"; Response.Headers.Add("content-length", stream.Length.ToString()); return(File(stream, "application/pdf", "adressen.pdf")); } return(RedirectToAction("Index")); }