Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "ID,Title,Description,Contents")] CVVM cvVM)
        {
            if (ModelState.IsValid)
            {
                CV cv = repo.GetCvById(cvVM.ID);
                if (cv == null)
                {
                    return(HttpNotFound());
                }

                cv.Title       = cvVM.Title;
                cv.Description = cvVM.Description;
                if (cvVM.Contents != null)
                {
                    cv.FileName = cvVM.Contents.FileName;
                    cv.MimeType = cvVM.Contents.ContentType;
                    BinaryReader binaryReader = new BinaryReader(cvVM.Contents.InputStream);
                    cv.Content = binaryReader.ReadBytes(cvVM.Contents.ContentLength);
                }

                repo.ChangeCv(cv);

                return(RedirectToAction("Index"));
            }

            return(View(cvVM));
        }