Ejemplo n.º 1
0
        public ActionResult UploadFile(Report report)
        {
            var rfvm = new ReportsFileViewModel();

            rfvm.report = report;
            return(View(rfvm));
        }
Ejemplo n.º 2
0
        public ActionResult UploadFile(ReportsFileViewModel rfvm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (rfvm.file.ContentLength > 0)
                    {
                        string _FileName = Path.GetFileName(rfvm.file.FileName);
                        string _path     = Path.Combine(Server.MapPath("~/App_Data/uploads"), _FileName);
                        rfvm.file.SaveAs(_path);
                        rfvm.report.ECGfile = _path;
                        db.Reports.Add(rfvm.report);
                        db.SaveChanges();
                        //if (User.IsInRole("Patient")){
                        //    return RedirectToAction("MyReports", "Reports", new { id = rfvm.report.PatientId });
                        //}
                        return(RedirectToAction("Details", "Patients", new { id = rfvm.report.PatientId }));
                    }
                }
                catch
                {
                    ViewBag.Message = "File upload failed!!";
                    return(View(rfvm));
                }
            }

            return(View(rfvm));
        }