コード例 #1
0
ファイル: LogController.cs プロジェクト: devtwocovetus/tchap
        public async Task <HttpResponseMessage> List(MT_Log_Book LBMD)
        {
            Db = con.SurgeryCenterDb(LBMD.Slug);
            LogResponse Response = new LogResponse();

            try
            {
                List <MT_Log_Book> PMList  = new List <MT_Log_Book>();
                Query         ObjQuery     = Db.Collection("MT_Log_Book");
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnap in ObjQuerySnap.Documents)
                    {
                        PMList.Add(Docsnap.ConvertTo <MT_Log_Book>());
                    }

                    Response.DataList = PMList;
                    Response.Status   = con.StatusSuccess;
                    Response.Message  = con.MessageSuccess;
                }
                else
                {
                    Response.Status  = con.StatusDNE;
                    Response.Message = con.MessageDNE;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #2
0
ファイル: LogController.cs プロジェクト: devtwocovetus/tchap
        public async Task <HttpResponseMessage> Create(MT_Log_Book LBMD)
        {
            Db = con.SurgeryCenterDb(LBMD.Slug);
            LogResponse Response = new LogResponse();

            try
            {
                UniqueID            = con.GetUniqueKey();
                LBMD.Unique_ID      = UniqueID;
                LBMD.Ip_Address     = GetClientIp();
                LBMD.Operation_Time = con.ConvertTimeZone(LBMD.TimeZone, Convert.ToDateTime(LBMD.Operation_Time));
                DocumentReference docRef = Db.Collection("MT_Log_Book").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(LBMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = LBMD;
                }
                else
                {
                    Response.Status  = con.StatusNotInsert;
                    Response.Message = con.MessageNotInsert;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }