示例#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"));
        }
示例#2
0
        //id as patient id
        public IActionResult Create(int id)
        {
            //get doctorID
            GlobalMethods globalMethods = new GlobalMethods(_context, _httpContextAccessor);
            int           DoctorId      = 0;

            if (globalMethods.GetDoctorId().HasValue)
            {
                DoctorId = globalMethods.GetDoctorId().Value;
            }
            if (DoctorId > 0)
            {
                PatientSurgeries patientSurgeries = new PatientSurgeries()
                {
                    DoctorId  = DoctorId,
                    PatientId = id,
                };
                IEnumerable <SurgeryType> SurgeryTypeList = _context.SurgeryType.ToList();
                SelectList SurgeryTypeId = new SelectList(SurgeryTypeList, "SurgeryTypeId", "SurgeryTypeName");
                ViewData["SurgeryTypeId"] = SurgeryTypeId;
                IEnumerable <PatientSurgeries> PatientSurgeryList = _context.PatientSurgeries.Include(x => x.Patient).Where(x => x.DoctorId == DoctorId && x.PatientId == id).ToList();
                ViewData["PatientSurgeryList"] = PatientSurgeryList;
                return(View(patientSurgeries));
            }
            return(RedirectToAction("Login", "Account"));
        }
示例#3
0
        //id is meant for surgery id
        public IActionResult Edit(int id)
        {
            PatientSurgeries            patientSurgeries = _context.PatientSurgeries.Where(x => x.SurgeryId == id).FirstOrDefault();
            IEnumerable <SurgeryImages> surgeryImages    = _context.SurgeryImages.Where(x => x.SurgeryId == id).ToList();
            SelectList SurgeryTypeList = new SelectList(_context.SurgeryType.ToList(), "SurgeryTypeId", "SurgeryTypeName");

            ViewData["SurgeryTypeId"] = SurgeryTypeList;
            ViewData["SurgeryImages"] = surgeryImages;
            return(View(patientSurgeries));
        }
示例#4
0
        public IActionResult ConfirmDelete([Bind("SurgeryId")] int SurgeryId)
        {
            bool existed   = _context.PatientSurgeries.Any(x => x.SurgeryId == SurgeryId);
            int? patientId = null;

            if (existed)
            {
                PatientSurgeries patientSurgeries = _context.PatientSurgeries.Where(x => x.SurgeryId == SurgeryId).FirstOrDefault();
                patientId = patientSurgeries.PatientId;
                List <SurgeryImages> surgeryImages = _context.SurgeryImages.Where(x => x.SurgeryId == SurgeryId).ToList();
                _context.RemoveRange(surgeryImages);
                _context.SaveChanges();
                _context.Remove(patientSurgeries);
                _context.SaveChanges();
            }
            return(RedirectToAction("Create", new { id = patientId }));
        }
示例#5
0
        //id is for surgery Id
        public IActionResult Delete(int id)
        {
            PatientSurgeries surgeries = _context.PatientSurgeries.Where(x => x.SurgeryId == id).FirstOrDefault();

            return(View(surgeries));
        }