Пример #1
0
        public HttpResponseMessage TrackeIn(InStudentTrack objInStudentTrack, string Token, string AppKey)
        {
            string strJson  = string.Empty;
            var    response = this.Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                //Accountmeg objaccountmegment = new Accountmeg();
                //string result = objaccountmegment.Getresult(AppKey, Token);
                string result = "true";
                if (result == "true")
                {
                    using (TTPAPIDataContext DB = new TTPAPIDataContext())
                    {
                        InStudentTrack objInStudentTracks = new InStudentTrack();
                        // objInStudentTracks.InDateTime = objInStudentTrack.InDateTime; - needto refactor this as the InDatetime will be from the server. This will not help mcuh if we implement the queing model for requests in the app.
                        objInStudentTracks.InDateTime = DateTime.Now;
                        objInStudentTracks.InLat      = objInStudentTrack.InLat;
                        objInStudentTracks.InLong     = objInStudentTrack.InLong;
                        objInStudentTracks.StudentId  = objInStudentTrack.StudentId;

                        DB.InStudentTracks.InsertOnSubmit(objInStudentTracks);
                        DB.SubmitChanges();

                        strJson          = "{\"Result\":\"204\"}";
                        response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                        return(response);
                    }
                }
                else
                {
                    strJson          = "{\"Result\":\"Invalide AppKey\"}";
                    response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                strJson          = "{\"Result\":\"" + ex.Message + "\"}";
                response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                return(response);
            }
        }
Пример #2
0
        public HttpResponseMessage InStudentTrack(InStudentTrack obInStudentTrack, string Token, string AppKey)
        {
            string strJson  = string.Empty;
            var    response = this.Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                Accountmeg objaccountmegment = new Accountmeg();
                string     result            = objaccountmegment.Getresult(AppKey, Token);
                if (result == "true")
                {
                    using (TTPAPIDataContext DB = new TTPAPIDataContext())
                    {
                        InStudentTrack objInStudentTracks = new InStudentTrack();
                        objInStudentTracks.InDateTime = obInStudentTrack.InDateTime;
                        objInStudentTracks.InLat      = obInStudentTrack.InLat;
                        objInStudentTracks.InLong     = obInStudentTrack.InLong;
                        objInStudentTracks.StudentId  = obInStudentTrack.StudentId;


                        DB.InStudentTracks.InsertOnSubmit(objInStudentTracks);
                        DB.SubmitChanges();

                        strJson          = "{\"Result\":\"204\"}";
                        response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                        return(response);
                    }
                }
                else
                {
                    strJson          = "{\"Result\":\"Invalide AppKey\"}";
                    response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                strJson          = "{\"Result\":\"" + ex.Message + "\"}";
                response.Content = new StringContent(strJson, Encoding.UTF8, "application/json");
                return(response);
            }
        }