コード例 #1
0
        public void CRUD()
        {
            e.location obj = new e.location()
            {
                name_en         = "testing",
                name_mm         = "testing",
                locationtype_id = null
            };

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

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

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

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

            //Delete
            e.shared.ActionResult delete_result = d.location.Delete(int.Parse(insert_result.Value.ToString())).Result;
        }
コード例 #2
0
        public static async Task <e.shared.ActionResult> Update(e.location obj)
        {
            using (var db = d.ConnectionFactory())
            {
                obj.modified_date = DateTime.Now;

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

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success
                });
            }
        }
コード例 #3
0
        public async Task <IActionResult> Put([FromBody] e.location obj)
        {
            try
            {
                e.shared.ActionResult result = await d.location.Update(obj);

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #4
0
        public static async Task <e.shared.ActionResult> Insert(e.location 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.location>(), obj);

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success, Value = id
                });
            }
        }
コード例 #5
0
        public async Task <IActionResult> Post([FromBody] e.location obj)
        {
            try
            {
                e.shared.ActionResult result = await d.location.Insert(obj);

                obj.location_id = int.Parse(result.Value.ToString());
                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }