Пример #1
0
        public async Task <IActionResult> Post([FromBody] Models.Core.Navigation data)
        {
            try
            {
                using (var db = new TM.Core.Connection.Oracle())
                {
                    var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization"));
                    if (nd == null)
                    {
                        return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() }));
                    }
                    if (db.Connection.isExist("ttkd_bkn.Navigation", "code", data.code))
                    {
                        return(Json(new { msg = TM.Core.Common.Message.exist.ToString() }));
                    }
                    data.created_by = nd.ma_nd;
                    data.created_at = DateTime.Now;
                    data.flag       = 1;
                    await db.Connection.InsertOraAsync(data);

                    return(Json(new { data = data, msg = TM.Core.Common.Message.success.ToString() }));
                }
            }
            catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); }
            finally { }
        }
Пример #2
0
        public async Task <IActionResult> Put([FromBody] Models.Core.Navigation data)
        {
            try
            {
                using (var db = new TM.Core.Connection.Oracle())
                {
                    var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization"));
                    if (nd == null)
                    {
                        return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() }));
                    }
                    var _data = await db.Connection.GetAsync <Models.Core.Navigation>(data.id);

                    if (_data != null)
                    {
                        _data.app_key    = data.app_key;
                        _data.dependent  = data.dependent;
                        _data.levels     = data.levels;
                        _data.title      = data.title;
                        _data.icon       = data.icon;
                        _data.image      = data.image;
                        _data.url        = data.url;
                        _data.url_plus   = data.url_plus;
                        _data.push       = data.push;
                        _data.go         = data.go;
                        _data.store      = data.store;
                        _data.orders     = data.orders;
                        _data.descs      = data.descs;
                        _data.updated_by = nd.ma_nd;
                        _data.updated_at = DateTime.Now;
                        _data.flag       = data.flag;
                    }
                    await db.Connection.UpdateAsync(_data);

                    return(Json(new { data = _data, msg = TM.Core.Common.Message.success.ToString() }));
                }
            }
            catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); }
            finally { }
        }