public static async Task <e.shared.ActionResult> Update(e.location_type obj) { using (var db = d.ConnectionFactory()) { await db.ExecuteAsync(d.Update <e.location_type>(), obj); return(new e.shared.ActionResult { Status = e.shared.Status.Success }); } }
public static async Task <e.shared.ActionResult> Insert(e.location_type obj) { using (var db = d.ConnectionFactory()) { int id = await db.ExecuteScalarAsync <int>(d.InsertAutoId <e.location_type>(), obj); return(new e.shared.ActionResult { Status = e.shared.Status.Success, Value = id }); } }
public async Task <IActionResult> Put([FromBody] e.location_type obj) { try { e.shared.ActionResult result = await d.location_type.Update(obj); return(Ok(obj)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Post([FromBody] e.location_type obj) { try { e.shared.ActionResult result = await d.location_type.Insert(obj); obj.locationtype_id = int.Parse(result.Value.ToString()); return(Ok(obj)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void CRUD() { e.location_type obj = new e.location_type() { name_en = "testing", name_mm = "testing" }; //Create e.shared.ActionResult insert_result = d.location_type.Insert(obj).Result; //Read obj = d.location_type.Get(int.Parse(insert_result.Value.ToString())).Result; //Read all IEnumerable <e.location_type> objs = d.location_type.Get().Result; //Update obj.name_en = "testing update"; e.shared.ActionResult update_result = d.location_type.Update(obj).Result; //Delete e.shared.ActionResult delete_result = d.location_type.Delete(int.Parse(insert_result.Value.ToString())).Result; }