// // GET: /Observations/Create public ViewResult Create() { var observation = new Observation() { ObservationDate = DateTime.Now }; return View(new ObservationFormViewModel(observation)); }
public ActionResult Create(Observation observation) { if (ModelState.IsValid) { this.service.AddObservation(observation); return RedirectToAction("Details", new { id = observation.ObservationId }); } return View(new ObservationFormViewModel(observation)); }
public ActionResult Create(Observation observation) { if (ModelState.IsValid) { db.Observations.Add(observation); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ObserveeId = new SelectList(db.Observees, "ObserveeId", "Name", observation.ObserveeId); return View(observation); }
public void CreatesANewObservation() { //Arrange _controller = new ObservationsController(_serviceMock.Object); var observation = new Observation() { ObservationDate = DateTime.Now }; // Act var result = _controller.Create(observation) as ViewResult; // Assert _serviceMock.Verify(x => x.AddObservation(observation), Times.Once()); }
// TODO: Add in error handling public void EditObservation(Observation observation) { db.Entry(observation).State = EntityState.Modified; db.SaveChanges(); }
// TODO: Add in error handling public void AddObservation(Observation observation) { db.Observations.Add(observation); db.SaveChanges(); }
public ObservationFormViewModel(Observation observation) { Observation = observation; Observees = new SelectList(db.Observees, "ObserveeId", "Name"); }
public void ShouldRetrieveObservationById() { // Arrange var expectedObservation = new Observation { ObservationId = 123 }; // Act _serviceMock.Setup(x => x.GetObservation(expectedObservation.ObservationId)).Returns(expectedObservation); _controller = new ObservationsController(_serviceMock.Object); dynamic result = _controller.Details(expectedObservation.ObservationId); // Assert Assert.AreSame(expectedObservation, result.Model); }
public ActionResult Edit(Observation observation) { if (ModelState.IsValid) { db.Entry(observation).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ObserveeId = new SelectList(db.Observees, "ObserveeId", "Name", observation.ObserveeId); return View(observation); }