Ejemplo n.º 1
0
        public void CRUD()
        {
            e.entry_points obj = new e.entry_points()
            {
                name_en = "testing",
                name_mm = "testing",
                lat     = 0,
                lon     = 0,
                remark  = "remark"
            };

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

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

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

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

            //Delete
            e.shared.ActionResult delete_result = d.entry_points.Delete(int.Parse(insert_result.Value.ToString())).Result;
        }
        public async Task <IActionResult> Put([FromBody] e.entry_points obj)
        {
            try
            {
                e.shared.ActionResult result = await d.entry_points.Update(obj);

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 3
0
        public static async Task <e.shared.ActionResult> Update(e.entry_points obj)
        {
            using (var db = d.ConnectionFactory())
            {
                obj.modified_date = DateTime.Now;

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

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success
                });
            }
        }
        public async Task <IActionResult> Post([FromBody] e.entry_points obj)
        {
            try
            {
                e.shared.ActionResult result = await d.entry_points.Insert(obj);

                obj.entrypoint_id = int.Parse(result.Value.ToString());
                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 5
0
        public static async Task <e.shared.ActionResult> Insert(e.entry_points 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_points>(), obj);

                return(new e.shared.ActionResult {
                    Status = e.shared.Status.Success, Value = id
                });
            }
        }