Exemple #1
0
        public ActionResult Create([Bind(Include = "ID,Title,Description,Contents")] CVVM cvVM)
        {
            if (ModelState.IsValid)
            {
                CV cv = new CV()
                {
                    Title       = cvVM.Title,
                    Description = cvVM.Description,
                    MimeType    = cvVM.Contents.ContentType,
                    Uploader    = repo.GetUserByName(User.Identity.Name),
                    FileName    = cvVM.Contents.FileName,
                    Content     = null
                };

                BinaryReader binaryReader = new BinaryReader(cvVM.Contents.InputStream);
                cv.Content = binaryReader.ReadBytes(cvVM.Contents.ContentLength);

                repo.AddCv(cv);

                return(RedirectToAction("Index"));
            }

            return(View(cvVM));
        }