Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetDeletedList(MT_KBCategory KCMD)
        {
            Db = con.SurgeryCenterDb(KCMD.Slug);
            KBCategoryResponse Response = new KBCategoryResponse();

            try
            {
                List <MT_KBCategory> List  = new List <MT_KBCategory>();
                Query         docRef       = Db.Collection("MT_KBCategory").WhereEqualTo("KBC_Is_Deleted", true).OrderBy("KBC_Category");
                QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        List.Add(Docsnapshot.ConvertTo <MT_KBCategory>());
                    }
                    Response.DataList = List;
                }
                Response.Status  = con.StatusSuccess;
                Response.Message = con.MessageSuccess;
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> Update(MT_KBCategory KCMD)
        {
            Db = con.SurgeryCenterDb(KCMD.Slug);
            KBCategoryResponse Response = new KBCategoryResponse();

            try
            {
                List <string> List = new List <string>();

                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "KBC_Sub_Category", KCMD.KBC_Sub_Category },
                    { "KBC_Category", KCMD.KBC_Category },
                    { "KBC_Description", KCMD.KBC_Description },
                    { "KBC_Modify_Date", con.ConvertTimeZone(KCMD.KBC_TimeZone, Convert.ToDateTime(KCMD.KBC_Modify_Date)) },
                    { "KBC_TimeZone", KCMD.KBC_TimeZone }
                };

                DocumentReference docRef = Db.Collection("MT_KBCategory").Document(KCMD.KBC_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = KCMD;
                }
                else
                {
                    Response.Status  = con.StatusNotUpdate;
                    Response.Message = con.MessageNotUpdate;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> CreateAsync(MT_KBCategory KCMD)
        {
            Db = con.SurgeryCenterDb(KCMD.Slug);
            KBCategoryResponse Response = new KBCategoryResponse();

            try
            {
                List <string> List = new List <string>();
                UniqueID             = con.GetUniqueKey();
                KCMD.KBC_Unique_ID   = UniqueID;
                KCMD.KBC_Create_Date = con.ConvertTimeZone(KCMD.KBC_TimeZone, Convert.ToDateTime(KCMD.KBC_Create_Date));
                KCMD.KBC_Modify_Date = con.ConvertTimeZone(KCMD.KBC_TimeZone, Convert.ToDateTime(KCMD.KBC_Modify_Date));

                DocumentReference docRef = Db.Collection("MT_KBCategory").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(KCMD);

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