コード例 #1
0
        //
        // GET: /Entry/
        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated == false)
                return JsonError("You are not authenticated");

            JournalModel model = new JournalModel(User.Identity.Name,DateTime.Today);

            return View(model);
        }
コード例 #2
0
        public JsonResult Save(JournalModel model)
        {
            if (User.Identity.IsAuthenticated == false)
                return JsonError("You are not authenticated");
            JourListDMContainer dm = new JourListDMContainer();

            var member = dm.Members.SingleOrDefault(z => z.Name == User.Identity.Name);
            if(member == null)
                return JsonError("You are not registered in the system");

            var journal = member.Journals.SingleOrDefault(z => z.Id == model.JourId);
            if (journal == null)
                return JsonError("You can't save a journal that doesn't exist. Or at least, technically you could by creating a new one... but that should have already been done.  If it hasn't already been done then you're working outside the system.");

            journal.Weight = model.Weight;
            journal.HeartRate = model.HeartRate;
            journal.Story = model.Story;
            journal.Encrypted = model.Encrypted;

            dm.SaveChanges();
            model.JourId = journal.Id;
            return JsonOk(model);
        }
コード例 #3
0
        public JsonResult GetEntry(string date = "", int id = -1)
        {
            if (User.Identity.IsAuthenticated == false)
                return JsonError("You are not authenticated");

            //JourListDMContainer dm = new JourListDMContainer();
            JournalModel model;
            if (date != string.Empty)
                model = new JournalModel(User.Identity.Name, DateTime.Parse(date));
            else if (id != -1)
                model = new JournalModel(User.Identity.Name, id);
            else
                model = new JournalModel(User.Identity.Name, DateTime.Today);

            return JsonOk(model);
        }