Ejemplo n.º 1
0
 public HttpResponseMessage PostRecordAttemptResult(CredentialAttempt ca)
 {
     if (ModelState.IsValid)
     {
         var result = QueryableDependencies.UpdateCredentialAttemptResult(ca);
         return Request.CreateResponse(HttpStatusCode.OK, result);
     }
     else
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
     }
 }
Ejemplo n.º 2
0
        public static string InsertProfileInfo(ProfileInfo pi)
        {
            CredentialAttempt ca = new CredentialAttempt();
            //Need to created ETicket???????
            ca.ETicket = Guid.NewGuid().ToString();
            ca.ProfileInfo = pi;
            TimeStamps ts = new TimeStamps(){Initiated = DateTime.UtcNow};
            ca.TimeStamps = ts;

            var newprofileinfo = BadgeApiDB.GetCollection("CredentialAttempt");
            try
            {
                newprofileinfo.Insert(ca);
            }
            catch (Exception ex)
            {
                // To do find the result and return????
            }

            return ca.ToJson();
        }
Ejemplo n.º 3
0
        public static string UpdateCredentialAttemptResult(CredentialAttempt ca)
        {
            var collection = BadgeApiDB.GetCollection<CredentialAttempt>("CredentialAttempt");
            var query = Query.EQ("ETicket", ca.ETicket);
            var result = collection.FindOne(query);

            if (result != null)
            {
                var update = Update<CredentialAttempt>.Set(e => e.Result, ca.Result); // update modifiers
                update.Set(e => e.TimeStamps.ResultReceived, DateTime.UtcNow);
                collection.Update(query, update);
                return result.ToJson();
            }
            else
            {
                //CredentialAttempt ca = new CredentialAttempt();
                //Need to created ETicket???????
                ca.ETicket = ca.ETicket;
                TimeStamps ts = new TimeStamps() { Initiated = DateTime.UtcNow, ResultReceived = DateTime.UtcNow };
                ca.TimeStamps = ts;

                var newprofileinfo = BadgeApiDB.GetCollection("CredentialAttempt");
                newprofileinfo.Insert(ca);
                return ca.ToJson();
            }
        }