private bool SetStarState(int trailMeetsId, bool newState)
        {
            // Create the service
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new TrailMeetService(userId);

            // Get the note
            var detail = service.GetTrailMeetById(trailMeetsId);

            // Create the NoteEdit model instance with the new star state
            var updateTrailMeets =
                new TrailMeetEdit
            {
                TrailMeetID    = detail.TrailMeetID,
                TrailTrackerID = detail.TrailTrackerID,
                TrailName      = detail.TrailName,
                OfTrailType    = detail.OfTrailType,
                MeetTime       = detail.MeetTime,
                MeetComments   = detail.MeetComments,
                JoinTrail      = newState
            };

            // Return a value indicating whether the update succeeded
            return(service.UpdateTrailMeet(updateTrailMeets));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateTrailMeetService();
            var detail  = service.GetTrailMeetById(id);
            var model   =
                new TrailMeetEdit
            {
                TrailMeetID    = detail.TrailMeetID,
                TrailTrackerID = detail.TrailTrackerID,
                TrailName      = detail.TrailName,
                OfTrailType    = detail.OfTrailType,
                MeetTime       = detail.MeetTime,
                MeetComments   = detail.MeetComments
            };

            ViewBag.TrailTrackerID = new SelectList(service.GetTrails(), "TrailTrackerID", "TrailName", model.TrailTrackerID);
            return(View(model));
        }
        public bool UpdateTrailMeet(TrailMeetEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .TrailMeets
                    .Single(e => e.TrailMeetID == model.TrailMeetID && e.OwnerID == _userId);

                entity.TrailMeetID    = model.TrailMeetID;
                entity.TrailTrackerID = model.TrailTrackerID;
                entity.OfTrailType    = model.OfTrailType;
                entity.Picture        = model.Picture;
                entity.JoinTrail      = model.JoinTrail;
                entity.MeetTime       = model.MeetTime;
                entity.MeetComments   = model.MeetComments;
                entity.ModifiedUtc    = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, TrailMeetEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.TrailMeetID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateTrailMeetService();

            if (service.UpdateTrailMeet(model))
            {
                TempData["SaveResult"] = "Your trail Meetup was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your trail Meetup could not be updated.");
            return(View(model));
        }