コード例 #1
0
 //
 // GET: /JournalEntry/Create
 public ActionResult Create()
 {
     var e = new JournalEntry()
     {
         EntryDate = DateTime.Now,
         Created = DateTime.Now,
         UserId = Guid.Parse(User.Identity.Name),
         RecordId = Guid.Parse(User.Identity.Name)
     };
     return View(e);
 }
コード例 #2
0
        public ActionResult Create(JournalEntry journalentry)
        {
            if (ModelState.IsValid)
            {
                // TODO use an Azure Queue that will be monitored by a worker role
                //add the custom type for health vault
                ItemTypeManager.RegisterTypeHandler(HVJournalEntry.TypeId, typeof(HVJournalEntry), true);

                // get the authed user
                var authorizedUser = (User as HVPrincipal);
                if (authorizedUser != null)
                {
                    //get the auth token
                    var authToken = authorizedUser.AuthToken;

                    // create the appropriate objects for health vault
                    var appId = HealthApplicationConfiguration.Current.ApplicationId;
                    WebApplicationCredential cred = new WebApplicationCredential(
                        appId,
                        authToken,
                        HealthApplicationConfiguration.Current.ApplicationCertificate);

                    // setup the user
                    WebApplicationConnection connection = new WebApplicationConnection(appId, cred);
                    PersonInfo personInfo = HealthVaultPlatform.GetPersonInfo(connection);

                    // before we add make sure we still have permission to add
                    var result = personInfo.SelectedRecord.QueryPermissionsByTypes(new List<Guid>() { HVJournalEntry.TypeId }).FirstOrDefault();
                    if (!result.Value.OnlineAccessPermissions.HasFlag(HealthRecordItemPermissions.Create))
                        throw new ArgumentNullException("unable to create record as no permission is given from health vault");

                    //Now add to the HV system
                    personInfo.SelectedRecord.NewItem(new HVJournalEntry(journalentry));

                    // redirect
                    return RedirectToAction("Index");
                }
            }

            return View(journalentry);
        }
コード例 #3
0
        public HVJournalEntry(JournalEntry entry)
            : base(new Guid("a5033c9d-08cf-4204-9bd3-cb412ce39fc0"))
        {
            m_when = new HealthServiceDateTime(DateTime.Now);

            // clone the entry coming in without reference to object
            JournalEntry = new JournalEntry()
            {
                Created = entry.Created,
                EntryDate = entry.EntryDate,
                Id = entry.Id,
                IsDay = entry.IsDay,
                Latitude = entry.Latitude,
                Longitude = entry.Longitude,
                MissedWorkSchool = entry.MissedWorkSchool,
                PeakFlowReading = entry.PeakFlowReading,
                RecordId = entry.RecordId,
                SawDoctor = entry.SawDoctor,
                SawEmergency = entry.SawEmergency,
                UserId = entry.UserId
            };
        }
コード例 #4
0
 public ActionResult Edit(JournalEntry journalentry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(journalentry).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(journalentry);
 }
コード例 #5
0
 public ActionResult Edit(JournalEntry journalentry)
 {
     return RedirectToAction("Index");
 }