Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> CreateAsync(MT_Nationality NMD)
        {
            Db = con.SurgeryCenterDb(NMD.Slug);
            NationalityResonse Response = new NationalityResonse();

            try
            {
                UniqueID             = con.GetUniqueKey();
                NMD.Nati_Unique_ID   = UniqueID;
                NMD.Nati_Create_Date = con.ConvertTimeZone(NMD.Nati_TimeZone, Convert.ToDateTime(NMD.Nati_Create_Date));
                NMD.Nati_Modify_Date = con.ConvertTimeZone(NMD.Nati_TimeZone, Convert.ToDateTime(NMD.Nati_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_Nationality").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(NMD);

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

            try
            {
                MT_Nationality Nati         = new MT_Nationality();
                Query          docRef       = Db.Collection("MT_Nationality").WhereEqualTo("Nati_Unique_ID", NMD.Nati_Unique_ID).WhereEqualTo("Nati_Is_Deleted", false);
                QuerySnapshot  ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    Nati          = ObjQuerySnap.Documents[0].ConvertTo <MT_Nationality>();
                    Response.Data = Nati;
                }
                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.º 3
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> GetDeletedList(MT_Nationality NMD)
        {
            Db = con.SurgeryCenterDb(NMD.Slug);
            NationalityResonse Response = new NationalityResonse();

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

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        AnesList.Add(Docsnapshot.ConvertTo <MT_Nationality>());
                    }
                    Response.DataList = AnesList.OrderBy(o => o.Nati_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));
        }
Ejemplo n.º 4
0
        public async Task <HttpResponseMessage> Remove(MT_Nationality NMD)
        {
            Db = con.SurgeryCenterDb(NMD.Slug);
            NationalityResonse Response = new NationalityResonse();

            try
            {
                DocumentReference docRef = Db.Collection("MT_Nationality").Document(NMD.Nati_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));
        }
Ejemplo n.º 5
0
        public async Task <HttpResponseMessage> UpdateAsync(MT_Nationality NMD)
        {
            Db = con.SurgeryCenterDb(NMD.Slug);
            NationalityResonse Response = new NationalityResonse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "Nati_Name", NMD.Nati_Name },
                    { "Nati_Modify_Date", con.ConvertTimeZone(NMD.Nati_TimeZone, Convert.ToDateTime(NMD.Nati_Modify_Date)) }
                };

                DocumentReference docRef = Db.Collection("MT_Nationality").Document(NMD.Nati_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

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