Esempio n. 1
0
        public IHttpActionResult GetNightData(int id)
        {
            var identity = (ClaimsIdentity)User.Identity;
            int l_userId = Int32.Parse(identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Single().Value);

            try
            {
                NightData l_nightData = (from row in db.NightDataContext where row.m_id == id && row.m_userId == l_userId select row).Single <NightData>();
                return(Ok(l_nightData));
            }
            catch (InvalidOperationException e)
            {
                return(NotFound());
            }
        }
Esempio n. 2
0
        public IHttpActionResult GetNightData(int p_userId, int p_dreamId)
        {
            // p_userId is only here to differentiate the 2 different nightdata gets
            var identity = (ClaimsIdentity)User.Identity;
            int l_userId = Int32.Parse(identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Single().Value);

            try
            {
                NightData l_nightData = (from row in db.NightDataContext where row.m_dreamId == p_dreamId && row.m_userId == l_userId select row).Single <NightData>();
                return(Ok(l_nightData));
            }
            catch (InvalidOperationException e)
            {
                return(NotFound());
            }
        }
Esempio n. 3
0
        public IHttpActionResult PutNightData(int p_toSleepTime, int p_sleepTime, int p_REMTime, int p_lucidDreamingTime, int p_dreamId)
        {
            var identity = (ClaimsIdentity)User.Identity;

            int l_userId = Int32.Parse(identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Single().Value);

            try
            {
                NightData l_newNightData = new NightData(p_toSleepTime, p_sleepTime, p_REMTime, p_lucidDreamingTime, p_dreamId, l_userId);

                db.NightDataContext.Add(l_newNightData);
                db.SaveChanges();

                return(Ok(l_newNightData));
            }
            catch (InvalidOperationException e)
            {
                return(NotFound());
            }
        }