Beispiel #1
0
        public IActionResult Create(PatientSurgeries patientSurgeries)
        {
            int?SurgeryId = null;

            if (ModelState.IsValid)
            {
                _context.PatientSurgeries.Add(patientSurgeries);
                _context.SaveChanges();
                SurgeryId = patientSurgeries.SurgeryId;
            }
            if (SurgeryId != null && SurgeryId > 0)
            {
                if (patientSurgeries.UploadedFiles != null)
                {
                    foreach (IFormFile file in patientSurgeries.UploadedFiles)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            file.CopyTo(ms);
                            SurgeryImages surgeryImage = new SurgeryImages()
                            {
                                ImageName    = file.FileName,
                                SurgeryImage = ms.ToArray(),
                                SurgeryId    = SurgeryId
                            };
                            _context.SurgeryImages.Add(surgeryImage);
                            _context.SaveChanges();
                        }
                    }
                }
            }
            return(RedirectToAction("Create"));
        }
Beispiel #2
0
        public void DeleteImage(int id)
        {
            SurgeryImages surgeryImages = _context.SurgeryImages.Where(x => x.SurgeryImageId == id).FirstOrDefault();

            _context.Remove(surgeryImages);
            _context.SaveChanges();
        }
Beispiel #3
0
        public JsonResult GetSelectedImage(int id)
        {
            SurgeryImages surgeryImages = _context.SurgeryImages.Where(x => x.SurgeryImageId == id).FirstOrDefault();

            return(Json(surgeryImages));
        }