Example #1
0
        public void CRUD()
        {
            e.entry_reason obj = new e.entry_reason()
            {
                name_en     = "testing",
                name_mm     = "testing",
                description = "description"
            };

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

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

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

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

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

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

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

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

                obj.reason_id = int.Parse(result.Value.ToString());
                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #5
0
        public static async Task <e.shared.ActionResult> Insert(e.entry_reason 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_reason>(), obj);

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