using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
Document doc = new Document(PageSize.A4, 30f, 30f, 30f, 30f);
PdfWriter writer = PdfWriter.GetInstance(doc, ms);
doc.Open();
BaseFont baseFont = BaseFont.CreateFont("C:\\Windows\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
//Заголовок
PdfContentByte cb = writer.DirectContent;
cb.Rectangle(10f, 10f, doc.PageSize.Width - 20f, doc.PageSize.Height - 20f);
cb.SetFontAndSize(baseFont, 13);
cb.BeginText();
cb.ShowTextAligned(
PdfContentByte.ALIGN_CENTER, "Отчёт", 300f, doc.PageSize.Height - 30f, 0);
cb.EndText();
cb.Stroke();
doc.Close();
}
public async Task<ActionResult> Create( Shop model, HttpPostedFileBase PhotoImage)
{
if (ModelState.IsValid)
{
byte[] imageData = null;
using (var binaryReader = new BinaryReader(PhotoImage.InputStream))
{
imageData = binaryReader.ReadBytes(PhotoImage.ContentLength);
}
model.Photo = imageData;
db.Shops.Add(model);
await db.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(model);
}
<input type="file" name="PhotoImage" />
public virtual ICollection<Player> Players { get; set; }
_context.Team.Include(p=>p.Player);
public partial class Order
{
public string CustomerName { get; set; }
public id CarLabelId { get; set; }
public CarLabel CarLabel { get; set; }
}
public class CarLabel
{
public int Id { get; set; }
public string NameCar { get; set; }
}
public class Check{
public int Id {get;set;}
public ICollection<ProductItem> ProductItem {get;set;}
}
public class Product{
public int Id {get;set;}
public ICollection<ProductItem> ProductItem {get;set;}
}
public class ProductItem{
public int ProductId {get;set;}
public Product Product {get;set;}
public int CheckId {get;set;}
public Check Check {get;set;}
public int Count {get;set;}
}
private readonly IApplicationEnvironment _appEnvironment;
public YourController(IApplicationEnvironment appEnvironment)
{
_appEnvironment = appEnvironment;
}
public ActionResult Create()
{
YourModel model = new YourModel();
string path = _appEnvironment.ApplicationBasePath + "\\wwwroot\\Content\\Default"; // получим путь к файловой системе
model.Photo = ImageToByte(path + "\\Image.png");
}
private byte[] ImageToByte(string path)
{
Image image = Image.FromFile(path);
MemoryStream memoryStream = new MemoryStream();
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
return memoryStream.ToArray();
}
@Html.Raw("<img style='width:50px;' src=\"data:image/jpeg;base64," + Convert.ToBase64String(Model.Photo) + "\" />")
context.Subdivs.Include(i=>i.Realtor).First(s=>s.Id == id):
var summ = _context.StatisticPlayers.Where(i => i.MatchId == 143 && i.CommandId == 9).Sum(n=>n.Goal).ToString();
var summ1 = _context.StatisticPlayers.Where(i => i.MatchId == 143 && i.CommandId == 1).Sum(n => n.Goal).ToString();
var calendar = _context.Matchs.Where(i => i.ChampionatId == id).Select(f => new List<string> {
_context.StatisticPlayers.Where(i => i.MatchId == 143 && i.CommandId == 9).Sum(n=>n.Goal).ToString(),
_context.StatisticPlayers.Where(i => i.MatchId == 143 && i.CommandId == 1).Sum(n => n.Goal).ToString()
});