Esempio n. 1
0
        public ActionResult Patient_Update([DataSourceRequest] DataSourceRequest request, EditPatientMedicalRecordsViewModel editRequest)
        {
            if (this.ModelState.IsValid)
            {
                if (editRequest.File.ContentLength > 0)
                {
                    var file          = editRequest.File;
                    var fileExtension = Path.GetExtension(file.FileName);

                    var medicalRecord = new MedicalRecord()
                    {
                        DentistId    = this.User.Identity.GetUserId(),
                        Extension    = fileExtension,
                        PatientId    = editRequest.Id,
                        OriginalName = file.FileName,
                    };

                    this.medicalRecords.AddNewMedicalRecord(medicalRecord);

                    var folder          = medicalRecord.Id % 10;
                    var virtualFileName = medicalRecord.FileName.ToString();

                    var path = Path.Combine(this.Server.MapPath(MedicalRecordsPath + folder), virtualFileName + fileExtension);
                    file.SaveAs(path);
                }
            }

            return(this.Json(new[] { editRequest }.ToDataSourceResult(request, this.ModelState)));
        }
        public ActionResult Patient_Update([DataSourceRequest]DataSourceRequest request, EditPatientMedicalRecordsViewModel editRequest)
        {
            if (this.ModelState.IsValid)
            {

                if (editRequest.File.ContentLength > 0)
                {
                    var file = editRequest.File;
                    var fileExtension = Path.GetExtension(file.FileName);

                    var medicalRecord = new MedicalRecord()
                    {
                        DentistId = this.User.Identity.GetUserId(),
                        Extension = fileExtension,
                        PatientId = editRequest.Id,
                        OriginalName = file.FileName,
                    };

                    this.medicalRecords.AddNewMedicalRecord(medicalRecord);

                    var folder = medicalRecord.Id % 10;
                    var virtualFileName = medicalRecord.FileName.ToString();

                    var path = Path.Combine(this.Server.MapPath(MedicalRecordsPath + folder), virtualFileName + fileExtension);
                    file.SaveAs(path);
                }
            }

            return this.Json(new[] { editRequest }.ToDataSourceResult(request, this.ModelState));
        }