コード例 #1
0
        public async Task <HttpResponseMessage> GetNotiTypeListFilterWithCatID(MT_Notification_Type NTMD)
        {
            Db = con.SurgeryCenterDb(NTMD.Slug);
            NotiTypeResponse Response = new NotiTypeResponse();

            try
            {
                List <MT_Notification_Type> NotiCateList = new List <MT_Notification_Type>();
                Query         ObjQuery     = Db.Collection("MT_Notification_Type").WhereEqualTo("NT_Is_Deleted", false).WhereEqualTo("NT_Is_Active", true).WhereEqualTo("NT_Category_ID", NTMD.NT_Category_ID).OrderBy("NT_Category_Name");
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnap in ObjQuerySnap.Documents)
                    {
                        NotiCateList.Add(Docsnap.ConvertTo <MT_Notification_Type>());
                    }
                    Response.Status   = con.StatusSuccess;
                    Response.Message  = con.MessageSuccess;
                    Response.DataList = NotiCateList;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
コード例 #2
0
        public async Task <HttpResponseMessage> Create(MT_Notification_Type NTMD)
        {
            Db = con.SurgeryCenterDb(NTMD.Slug);
            NotiTypeResponse Response = new NotiTypeResponse();

            try
            {
                UniqueID          = con.GetUniqueKey();
                NTMD.NT_Unique_ID = UniqueID;
                Query         ObjQuery     = Db.Collection("MT_Notification_Type");
                QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    NTMD.NT_Category_Type_Code = "NTT000" + ObjQuerySnap.Documents.Count + 1.ToString();
                }
                else
                {
                    NTMD.NT_Category_Type_Code = "NTT000" + "1";
                }
                NTMD.NT_Create_Date = con.ConvertTimeZone(NTMD.NT_TimeZone, Convert.ToDateTime(NTMD.NT_Create_Date));
                NTMD.NT_Modify_Date = con.ConvertTimeZone(NTMD.NT_TimeZone, Convert.ToDateTime(NTMD.NT_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_Notification_Type").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(NTMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = NTMD;
                }
                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));
        }