private void FillSelf(Document model) { Id = model.Id; Name = model.Name; Data = model.Data; }
public ActionResult SaveFile() { if (!CurUser.UserCanEdit()) return RedirectToAction("AccessDenied", "Error"); int id = 0; if (Request.Files.Count > 0) { try { string noPdf = String.Empty; for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (Path.GetExtension(file.FileName) != ".pdf") { noPdf = "Файлы не PDF формата не были добавлены"; continue; } byte[] fileData = null; using (var br = new BinaryReader(file.InputStream)) { fileData = br.ReadBytes(file.ContentLength); } var doc = new Document() { Data = fileData, Name = file.FileName }; ResponseMessage responseMessage; bool complete = doc.Save(out responseMessage); if (!complete) throw new Exception(responseMessage.ErrorMessage); TempData["noPdf"] = noPdf; } } catch (Exception ex) { ViewData["ServerError"] = ex.Message; return View("Links"); } } return RedirectToAction("Links", id); //return RedirectToAction("Index", "Calc", new { claimId = Request.QueryString["claimId"] }); }