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

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

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success
                });
            }
        }
Beispiel #2
0
        public static async Task <e.shared.ActionResult> Insert(e.entry_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.entry_record>(), obj);

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success, Value = id
                });
            }
        }
        public async Task <IActionResult> Put([FromBody] e.entry_record obj)
        {
            try
            {
                obj.entrance_date = fn.GetLocalDateTime(obj.entrance_date);
                obj.person_dob    = fn.GetLocalDateTime(obj.person_dob);
                e.shared.ActionResult result = await d.entry_record.Update(obj);

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> Post([FromBody] e.entry_record obj)
        {
            try
            {
                obj.entrance_date = fn.GetLocalDateTime(obj.entrance_date);
                obj.person_dob    = fn.GetLocalDateTime(obj.person_dob);
                e.shared.ActionResult result = await d.entry_record.Insert(obj);

                obj.id = int.Parse(result.Value.ToString());
                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public void CRUD()
        {
            e.entry_record obj = new e.entry_record()
            {
                entrypoint_id     = null,
                entrance_date     = DateTime.Now,
                person_name       = "test person",
                person_nrc        = "test nrc",
                person_ph         = "test phone",
                person_age        = "1",
                person_dob        = DateTime.Now,
                gender            = "male",
                hometown          = "Yangon",
                reason_id         = null,
                travel_history    = "test history",
                residence_address = "test address",
                current_address   = "current address",
                traveled_from     = "test from",
                fever_history     = "test fever history",
                remark            = "test remark"
            };

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

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

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

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

            //Delete
            e.shared.ActionResult delete_result = d.entry_record.Delete(int.Parse(insert_result.Value.ToString())).Result;
        }