Esempio n. 1
0
        //[Authorize(Roles ="SAdmin")]
        public async Task <HttpResponseMessage> GetDeletedList(MT_Race RAMD)
        {
            Db = con.SurgeryCenterDb(RAMD.Slug);
            RaceResponse Response = new RaceResponse();

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

                if (ObjQuerySnap != null)
                {
                    foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents)
                    {
                        AnesList.Add(Docsnapshot.ConvertTo <MT_Race>());
                    }
                    Response.DataList = AnesList.OrderBy(o => o.Race_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. 2
0
        public async Task <HttpResponseMessage> CreateAsync(MT_Race RAMD)
        {
            Db = con.SurgeryCenterDb(RAMD.Slug);
            RaceResponse Response = new RaceResponse();

            try
            {
                UniqueID              = con.GetUniqueKey();
                RAMD.Race_Unique_ID   = UniqueID;
                RAMD.Race_Create_Date = con.ConvertTimeZone(RAMD.Race_TimeZone, Convert.ToDateTime(RAMD.Race_Create_Date));
                RAMD.Race_Modify_Date = con.ConvertTimeZone(RAMD.Race_TimeZone, Convert.ToDateTime(RAMD.Race_Modify_Date));
                DocumentReference docRef = Db.Collection("MT_Race").Document(UniqueID);
                WriteResult       Result = await docRef.SetAsync(RAMD);

                if (Result != null)
                {
                    Response.Status  = con.StatusSuccess;
                    Response.Message = con.MessageSuccess;
                    Response.Data    = RAMD;
                }
                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. 3
0
        //[Authorize(Roles = "Admin")]
        public async Task <HttpResponseMessage> GetAsync(MT_Race RAMD)
        {
            Db = con.SurgeryCenterDb(RAMD.Slug);
            RaceResponse Response = new RaceResponse();

            try
            {
                MT_Race       Race         = new MT_Race();
                Query         docRef       = Db.Collection("MT_Race").WhereEqualTo("Race_Unique_ID", UniqueID).WhereEqualTo("Race_Is_Deleted", false);
                QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync();

                if (ObjQuerySnap != null)
                {
                    Race          = ObjQuerySnap.Documents[0].ConvertTo <MT_Race>();
                    Response.Data = Race;
                }
                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_Race RAMD)
        {
            Db = con.SurgeryCenterDb(RAMD.Slug);
            RaceResponse Response = new RaceResponse();

            try
            {
                DocumentReference docRef = Db.Collection("MT_Race").Document(RAMD.Race_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
        private async Task <RaceResponse> Retrieve(StaticVault vault, String id)
        {
            RaceResponse retrieved = await vault.Race.Retrieve(id);

            Console.WriteLine("//// RaceExample.retrieve:");
            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(retrieved));

            return(retrieved);
        }
Esempio n. 6
0
        private async Task <RaceResponse> Create(StaticVault vault)
        {
            String name = "example";

            RaceResponse created = await vault.Race.Create(name);

            Console.WriteLine("//// RaceExample.create:");
            Console.WriteLine("/// Name: " + name);
            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(created));

            return(created);
        }
Esempio n. 7
0
        public async Task Run()
        {
            // Creating a new Race
            RaceResponse created = await Create(staticVault);

            // Retrieving a existent Race
            RaceResponse retrieved = await Retrieve(staticVault, created.Id);

            await RetrieveFromRealData(staticVault, created.Race);

            // Deleting a existent Race
            await Delete(staticVault, retrieved.Id);
        }
Esempio n. 8
0
        public async Task Run()
        {
            var sdk    = new Nullafi.NullafiSDK(Environment.GetEnvironmentVariable("API_KEY"));
            var client = await sdk.CreateClient();

            var staticVault = await client.CreateStaticVault("Address Vault Example", null);

            RaceResponse created = await Create(staticVault);

            RaceResponse retrieved = await Retrieve(staticVault, created.Id);

            await RetrieveFromRealData(staticVault, created.Race);
            await Delete(staticVault, retrieved.Id);

            await client.DeleteStaticVault(staticVault.VaultId);
        }
Esempio n. 9
0
        public async Task <HttpResponseMessage> UpdateAsync(MT_Race RAMD)
        {
            Db = con.SurgeryCenterDb(RAMD.Slug);
            RaceResponse Response = new RaceResponse();

            try
            {
                Dictionary <string, object> initialData = new Dictionary <string, object>
                {
                    { "Race_Type", RAMD.Race_Type },
                    { "Race_Name", RAMD.Race_Name },
                    { "PhyO_Modify_Date", con.ConvertTimeZone(RAMD.Race_TimeZone, Convert.ToDateTime(RAMD.Race_Modify_Date)) }
                };

                DocumentReference docRef = Db.Collection("MT_Race").Document(RAMD.Race_Unique_ID);
                WriteResult       Result = await docRef.UpdateAsync(initialData);

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