Ejemplo n.º 1
0
        public ActionResult Close(TripClosureViewModel tcvm)
        {
            if (!tcvm.TripId.HasValue)
            {
                return new NoSuchTripResult();
            }

            var repo = new TubsRepository<Trip>(MvcApplication.CurrentSession);
            var trip = repo.FindBy(tcvm.TripId.Value);
            if (null == trip)
            {
                return new NoSuchTripResult();
            }

            // Idempotent -- if the trip is already closed, just push to the details page
            if (!trip.IsReadOnly)
            {
                trip.ClosedDate = DateTime.Now;
                trip.Comments = tcvm.Comments;
                try
                {
                    repo.Update(trip);
                }
                catch (Exception ex)
                {
                    Flash("Unable to close trip -- contact technical support");
                    Logger.Error("Error while closing trip", ex);
                }

            }

            // Pull page just for closing trip.  Modal is fine, although may want to make it larger.
            //return View(tcvm);
            return RedirectToAction("Details", "Trip", new { tripId = trip.Id });
        }
Ejemplo n.º 2
0
 public void ModifyVesselAttributes()
 {
     var transaction = this.session.BeginTransaction();
     var trip = new TubsRepository<Trip>(this.session).FindBy(103) as PurseSeineTrip;
     Assert.NotNull(trip);
     var attributes = trip.VesselAttributes;
     Assert.NotNull(attributes);
     attributes.HelicopterMake = "Hughes";
     attributes.HelicopterModel = "MD 500 Defender";
     var repo = new TubsRepository<PurseSeineVesselAttributes>(this.session);
     repo.Update(attributes);
     transaction.Commit();
 }