public async Task <ActionResult> PostPdf() { var pdf = (Pdf)null; var tuple = await ExtractFile(); if (tuple.Item1 != null) { pdf = new Pdf { Content = tuple.Item1, Size = tuple.Item1.Length, Title = tuple.Item2, UploadDate = DateTime.UtcNow }; var results = new List <ValidationResult>(); bool isValid = Validator.TryValidateObject(pdf, new ValidationContext(pdf, null, null), results, true); if (isValid) { await _pdfService.InsertPdf(pdf); return(CreatedAtAction(nameof(GetPdf), new { id = pdf.Id }, pdf)); } } return(BadRequest(ModelState)); }