public static async Task <e.shared.ActionResult> Update(e.quarantine_record obj)
        {
            using (var db = d.ConnectionFactory())
            {
                obj.modified_date = DateTime.Now;

                await db.ExecuteAsync(d.Update <e.quarantine_record>(), obj);

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success
                });
            }
        }
Exemple #2
0
        public void CRUD()
        {
            var list = d.quarantine_record.Get(new e.quarantine_recordParam
            {
                PgNo = 1
            });

            e.quarantine_record obj = new e.quarantine_record()
            {
                station_id        = null,
                start_date        = DateTime.Now,
                end_date          = DateTime.Now,
                person_name       = "test name",
                person_nrc        = "test nrc",
                person_ph         = "test phone",
                person_age        = "0",
                person_dob        = DateTime.Now,
                gender            = "male",
                hometown          = "test home town",
                reason_id         = null,
                travel_history    = "test history",
                residence_address = "residence address",
                current_address   = "current address",
                traveled_from     = "travel from",
                fever_history     = "fever history",
                remark            = "test remark",
                checkout_date     = DateTime.Now,
                result            = "test result",
                lab_testing       = true,
                lab_testing_date  = DateTime.Now,
                result_date       = DateTime.Now,
                checkedout        = false
            };

            //Create
            e.shared.ActionResult insert_result = d.quarantine_record.Insert(obj).Result;

            //Read
            obj = d.quarantine_record.Get(int.Parse(insert_result.Value.ToString())).Result;

            //Read all
            IEnumerable <e.quarantine_record> objs = d.quarantine_record.Get().Result;

            //Update
            obj.person_name = "testing update";
            e.shared.ActionResult update_result = d.quarantine_record.Update(obj).Result;

            //Delete
            e.shared.ActionResult delete_result = d.quarantine_record.Delete(int.Parse(insert_result.Value.ToString())).Result;
        }
        public static async Task <e.shared.ActionResult> Insert(e.quarantine_record obj)
        {
            using (var db = d.ConnectionFactory())
            {
                obj.creation_date = DateTime.Now;
                obj.modified_date = DateTime.Now;

                int id = await db.ExecuteScalarAsync <int>(d.InsertAutoId <e.quarantine_record>(), obj);

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success, Value = id
                });
            }
        }
        public async Task <IActionResult> Put([FromBody] e.quarantine_record obj)
        {
            try
            {
                obj.start_date       = fn.GetLocalDateTime(obj.start_date);
                obj.end_date         = fn.GetLocalDateTime(obj.end_date);
                obj.person_dob       = fn.GetLocalDateTime(obj.person_dob);
                obj.checkout_date    = fn.GetLocalDateTime(obj.checkout_date);
                obj.lab_testing_date = fn.GetLocalDateTime(obj.lab_testing_date);
                obj.result_date      = fn.GetLocalDateTime(obj.result_date);

                e.shared.ActionResult result = await d.quarantine_record.Update(obj);

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }