예제 #1
0
        public ActionResult Index(MyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.Clear();
            }

            FileUploadDBModel fileUploadModel = new FileUploadDBModel();

            byte[] uploadFile = new byte[model.File.InputStream.Length];
            model.File.InputStream.Read(uploadFile, 0, uploadFile.Length);

            fileUploadModel.FileName        = model.File.FileName;
            fileUploadModel.File            = uploadFile;
            fileUploadModel.FullName        = model.FullName;
            fileUploadModel.Email           = model.Email;
            fileUploadModel.PhoneNumber     = model.PhoneNumber;
            fileUploadModel.DesiredJobTitle = model.DesiredJobTitle;

            db.FileUploadDBModels.Add(fileUploadModel);
            db.SaveChanges();
            ViewBag.message = "Dear User!You have Successfully uploaded your resume!";
            return(View());

            //return Content("File Uploaded.");
        }
        public ActionResult Index(FileUploadDBModel model)
        {
            int PatientI = Convert.ToInt32(System.Web.HttpContext.Current.Session["Id"]);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            #region
            //PatientFile fileUploadModel = new PatientFile();
            ////add loop for multiple file upload at same time
            //foreach(var item in model.File)
            //{
            //    byte[] uploadfile = new byte[item.InputStream.Length];
            //    item.InputStream.Read(uploadfile, 0, uploadfile.Length);

            //    fileUploadModel.FileName = item.FileName;
            //    fileUploadModel.File = uploadfile;

            //    db.PatientFiles.Add(fileUploadModel);
            //    db.SaveChanges();
            //}
            #endregion
            bu.InsertMethod(model, PatientI);
            //return Content("File successfull Uploaded");
            return(RedirectToAction("Download", "UploadFile"));
        }
예제 #3
0
        public FileContentResult FileDownload(int?id)
        {
            byte[] fileData;
            string fileName;

            FileUploadDBModel fileRecord = db.FileUploadDBModels.Find(id);

            fileData = (byte[])fileRecord.File.ToArray();
            fileName = fileRecord.FileName;

            return(File(fileData, "text", fileName));
        }
        public ActionResult Index(int patientId)
        {
            var name = db.Patients.ToList().Find(x => x.PatientId == patientId);

            System.Web.HttpContext.Current.Session["Id"] = patientId;
            var model = new FileUploadDBModel()
            {
                patientName = name.FullName.ToUpper() + " " + name.Surname.ToUpper()
            };

            return(View(model));
        }
예제 #5
0
        public FileContentResult FileDownload(int?id)
        {
            byte[] fileData;
            string fileName;

            FileUploadDBModel fileRecord = db.FileUploadDBModels.Find(id);

            fileData                   = (byte[])fileRecord.File.ToArray();
            fileName                   = fileRecord.FileName;
            fileRecord.FullName        = fileRecord.FullName;
            fileRecord.Email           = fileRecord.Email;
            fileRecord.PhoneNumber     = fileRecord.PhoneNumber;
            fileRecord.DesiredJobTitle = fileRecord.DesiredJobTitle;

            return(File(fileData, "text", fileName));
        }
예제 #6
0
        public ActionResult Index(MyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            FileUploadDBModel fileUploadModel = new FileUploadDBModel();

            byte[] uploadFile = new byte[model.File.InputStream.Length];
            model.File.InputStream.Read(uploadFile, 0, uploadFile.Length);

            fileUploadModel.FileName = model.File.FileName;
            fileUploadModel.File     = uploadFile;

            db.FileUploadDBModels.Add(fileUploadModel);
            db.SaveChanges();

            return(Content("File Uploaded."));
        }
        public void InsertMethod(FileUploadDBModel model, int PatientId)
        {
            PatientFile       fileUpload = new PatientFile();
            PatientRepository pr         = new PatientRepository();

            //add loop for multiple file upload at same time
            using (var Filerepo = new UploadRepository())
            {
                var name = pr.GetAll().Find(x => x.PatientId == PatientId);
                foreach (var item in model.File)
                {
                    byte[] uploadfile = new byte[item.InputStream.Length];
                    item.InputStream.Read(uploadfile, 0, uploadfile.Length);

                    fileUpload.FileName    = item.FileName;
                    fileUpload.File        = uploadfile;
                    fileUpload.PatientId   = PatientId;
                    fileUpload.patientName = name.FullName + " " + name.Surname;
                    Filerepo.Insert(fileUpload);
                }
            }
        }
        public ActionResult Main()
        {
            var model = new FileUploadDBModel();

            return(PartialView(model));
        }