public ActionResult Edit(int id, Patient PatientModel) { try { // TODO: Add update logic here Service.Edit(id, PatientModel); return(RedirectToAction("Index")); } catch { return(View()); } }
public void Should_Return_Edit_Success_Response() { var result = _patientService.Edit(new PatientModel { Id = 1, PatientName = "Gus Leo Ganteng", Gender = Gender.Male, PatientStatus = PatientStatus.Active, RelationshipStatus = RelationshipStatus.Other }); Assert.NotNull(result.Item); Assert.Equal(MessageConstant.Update, result.Message); Assert.True(result.Success); }
public async Task EditShouldReturnTrueAndEditedPatient() { var db = Tests.GetDatabase(); var doctorService = new DoctorService(db, null); var departmentService = new DepartmentService(db); await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL"); await db.SaveChangesAsync(); await doctorService.CreateAsync( "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology"); await db.SaveChangesAsync(); var patientService = new PatientService(db); var result = await patientService.Create("Patient", "8698969896", 28, "*****@*****.**"); await db.SaveChangesAsync(); var id = await db.Patients .Where(d => d.Name == "Patient") .Select(d => d.Id) .FirstOrDefaultAsync(); var edited = await patientService .Edit(id, "PatientEdited", "8698969896", 28, "*****@*****.**"); edited.Should() .BeTrue(); db.Patients.Should() .HaveCount(1); result.Should() .BeTrue(); }