public JsonResult CreateActivityLog(ActivityLogModel model)
        {
            var dm = new JourListDMContainer();
            var log = new ActivityLog();
            var member = dm.Members.SingleOrDefault(z => z.Name == User.Identity.Name);
            if (member == null)
                return JsonError("You don't exist");

            var journal = member.Journals.Single(z => z.Id == model.JourId);
            if (journal == null)
                return JsonError("This journal doesn't belong to you");

            log.Activity = dm.Activities.Single(z => z.Id == model.ActId);
            log.Quantity = model.Quantity;
            // TODO: Hyperlink & Notes should be updated to default to an
            //       empty string in the databaseif the value are null,
            //       the EM has been updated, but the database needs to
            //       be updated to reflect the default value of "".
            log.Notes = model.Notes;
            log.Hyperlink = model.Hyperlink;
            log.Unit = dm.Units.Single(z => z.Id == model.UnitId);
            log.Journal = journal;
            dm.ActivityLogs.AddObject(log);
            dm.SaveChanges();
            //            model.Points = log.Activity.Points;
            //            model.TotalPoints = (int)Math.Round(log.Activity.Points * log.Quantity);
            model.LogId = log.Id;
            //            return Json(model);
            return Json(new { Result = "OK", Record = model });
            //            return JsonError("Not Done");
        }
        public JsonResult UpdateActivityLog(ActivityLogModel model)
        {
            JourListDMContainer dm = new JourListDMContainer();
            if (User.Identity.IsAuthenticated != true)
                return JsonError("Please log in");

            var member = dm.Members.SingleOrDefault(z => z.Name == User.Identity.Name);
            if ( member == null)
                return JsonError("You do not exist");

            var log = dm.ActivityLogs.SingleOrDefault(z => z.Id == model.LogId);
            if ( log == null )
                return JsonError("That log does not exist");

            if (log.Journal.Member != member)
                return JsonError("This log does not belong to you");

            var unit = dm.Units.SingleOrDefault(z => z.Id == model.UnitId);
            if (unit == null)
                return JsonError("A unit by that ID does not exist");
            if (unit.UnitType != log.Activity.Unit.UnitType)
                return JsonError("Your unit is not the same type as the activity's");

            log.Unit = unit;
            log.Hyperlink = model.Hyperlink;
            log.Notes = model.Notes;
            log.Quantity = model.Quantity;

            dm.SaveChanges();

            return JsonOk(model);
        }