public void CRUD()
        {
            e.patient_history obj = new e.patient_history()
            {
                type         = "testing",
                coordinatesx = 34.8001090000001f,
                coordinatesy = 32.008471f,
                name         = "testing name",
                place        = "testing place",
                comments     = "testing comments",
                pointx       = 32.008471f,
                pointy       = 34.800109f,
                fromtime     = 1584691200000,
                totime       = 1584709200000,
                sourceoid    = 1,
                staytimes    = "10:00 - 15:00",
                remark       = "remark"
            };

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

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

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

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

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

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

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

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

                obj.id = int.Parse(result.Value.ToString());
                return(Ok(obj));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #5
0
        public static async Task <e.shared.ActionResult> Insert(e.patient_history obj)
        {
            using (var db = d.ConnectionFactory())
            {
                obj.creation_date = DateTime.Now;
                obj.modified_date = DateTime.Now;

                long id = await db.ExecuteScalarAsync <int>(d.InsertAutoId <e.patient_history>(), obj);

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