Ejemplo n.º 1
0
        public IActionResult PatientUpdate(HastalikTakibi.Models.PatientVm patient)
        {
            var patientDb = _hastlikTakipDbContext.Patients.Where(a => a.Id == patient.Id).FirstOrDefault();

            if (patientDb == null)
            {
                ViewBag.Error = "Hasta Bulunamadı";
                return(RedirectToAction("Index"));
            }
            if (patient == null || string.IsNullOrEmpty(patient.Name))
            {
                ViewBag.Error = "Lütfen zorunlu alanları doldurun";


                return(View(patient));
            }
            patientDb.Name           = patient.Name;
            patientDb.Surname        = patient.Surname;
            patientDb.Address        = patient.Address;
            patientDb.EMail          = patient.EMail;
            patientDb.TC             = patient.TC;
            patientDb.Phone          = patient.Phone;
            patientDb.Province       = patient.Province;
            patientDb.District       = patient.District;
            patientDb.LastUpdateTime = DateTime.Now;
            _hastlikTakipDbContext.Entry(patientDb).State = Microsoft.EntityFrameworkCore.EntityState.Modified;



            _hastlikTakipDbContext.SaveChangesAsync().GetAwaiter().GetResult();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public IActionResult PatientAdd(HastalikTakibi.Models.PatientVm patient)
        {
            if (patient == null || string.IsNullOrEmpty(patient.Name))
            {
                ViewBag.Error = "Lütfen zorunlu alanları doldurun";
                return(View(patient));
            }
            var patientDb = new Patient()
            {
                CreateTime = DateTime.Now,
                Name       = patient.Name,
                Surname    = patient.Surname,
                Address    = patient.Address,
                EMail      = patient.EMail,
                TC         = patient.TC,
                Phone      = patient.Phone,
                Province   = patient.Province,
                District   = patient.District
            };

            _hastlikTakipDbContext.Patients.Add(patientDb);
            _hastlikTakipDbContext.SaveChangesAsync().GetAwaiter().GetResult();
            return(RedirectToAction("Index"));
        }