Esempio n. 1
0
        public async Task <HttpResponseMessage> CreateAsync(MT_Supplies SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            SuppliesResponse Response = new SuppliesResponse();

            try
            {
                UniqueID             = con.GetUniqueKey();
                SMD.Supp_Unique_ID   = UniqueID;
                SMD.Supp_Create_Date = con.ConvertTimeZone(SMD.Supp_TimeZone, Convert.ToDateTime(SMD.Supp_Create_Date));
                SMD.Supp_Modify_Date = con.ConvertTimeZone(SMD.Supp_TimeZone, Convert.ToDateTime(SMD.Supp_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_Supplies").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(SMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = SMD;
                }
                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));
        }
Esempio n. 2
0
        //[Authorize(Roles = "Admin")]
        public async Task <HttpResponseMessage> Select(MT_Supplies SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            SuppliesResponse Response = new SuppliesResponse();

            try
            {
                MT_Supplies   Supp         = new MT_Supplies();
                Query         docRef       = Db.Collection("MT_Supplies").WhereEqualTo("Supp_Unique_ID", SMD.Supp_Unique_ID).WhereEqualTo("Supp_Is_Deleted", false);
                QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    Supp          = ObjQuerySnap.Documents[0].ConvertTo <MT_Supplies>();
                    Response.Data = Supp;
                }
                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));
        }
Esempio n. 3
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> GetDeletedList(MT_Supplies SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            SuppliesResponse Response = new SuppliesResponse();

            try
            {
                List <MT_Supplies> AnesList = new List <MT_Supplies>();
                Query         docRef        = Db.Collection("MT_Supplies").WhereEqualTo("Supp_Is_Deleted", true);
                QuerySnapshot ObjQuerySnap  = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        AnesList.Add(Docsnapshot.ConvertTo <MT_Supplies>());
                    }
                    Response.DataList = AnesList.OrderBy(o => o.Supp_Name).ToList();
                }
                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));
        }
Esempio n. 4
0
        public async Task <HttpResponseMessage> Remove(MT_Supplies SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            SuppliesResponse Response = new SuppliesResponse();

            try
            {
                DocumentReference docRef = Db.Collection("MT_Supplies").Document(SMD.Supp_Unique_ID);
                WriteResult       Result = await docRef.DeleteAsync();

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = null;
                }
                else
                {
                    Response.Status  = con.StatusNotDeleted;
                    Response.Message = con.MessageNotDeleted;
                    Response.Data    = null;
                }
            }
            catch (Exception ex)
            {
                Response.Status  = con.StatusFailed;
                Response.Message = con.MessageFailed + ", Exception : " + ex.Message;
            }
            return(ConvertToJSON(Response));
        }
Esempio n. 5
0
        public async Task <HttpResponseMessage> UpdateAsync(MT_Supplies SMD)
        {
            Db = con.SurgeryCenterDb(SMD.Slug);
            SuppliesResponse Response = new SuppliesResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "Supp_Type", SMD.Supp_Type },
                    { "Supp_Name", SMD.Supp_Name },
                    { "Supp_Description", SMD.Supp_Description },
                    { "Supp_Modify_Date", con.ConvertTimeZone(SMD.Supp_TimeZone, Convert.ToDateTime(SMD.Supp_Modify_Date)) }
                };

                DocumentReference docRef = Db.Collection("MT_Supplies").Document(SMD.Supp_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

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