Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var result = bs.dbResult <List <Object[]> >();
            await bs.dbAsync(false, "test", async (db) => {
                result = await db.selectAsync <List <Object[]> >("a", "title", "1PD시험a");
                return(true);
            });

            return(Json(new { data = result.result, a = bs.before(this), b = bs.fr <string>(true, "test.html") }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> list()
        {
            var before = (Dictionary <string, object>)bs.before(this);

            if (null == before)
            {
                if (null == bs.s("valiError"))
                {
                    return(bs.apiFail("알 수 없는 에러 발생"));
                }
                else
                {
                    return(bs.apiFail((Dictionary <string, bs.ValiResult>)bs.s("valiError")));
                }
            }
            List <Dictionary <String, String> > catList      = null;
            List <Dictionary <String, String> > contentsList = null;
            string errorMsg = null;
            await bs.dbAsync(false, "remote", async (db) => {
                var rs = await db.selectAsync <List <Dictionary <String, String> > >("contents/cat_list");
                if (rs.noRecord || rs.valiError)
                {
                    errorMsg = "컨텐츠 종류 정보를 가져오지 못했습니다.";
                    return(false);
                }
                catList = rs.result;
                rs      = await db.selectAsync <List <Dictionary <String, String> > >("contents/list", before);
                if (rs.noRecord || rs.valiError)
                {
                    errorMsg = "컨텐츠 정보를 가져오지 못했습니다.";
                    return(false);
                }
                contentsList = rs.result;
                return(true);
            });

            if (errorMsg != null)
            {
                return(bs.apiFail(errorMsg));
            }
            return(bs.apiOk(new { cat = catList, list = contentsList }));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> add()
        {
            var before = (Dictionary <string, object>)bs.before(this);

            if (before == null)
            {
                if (bs.s("valiError") == null)
                {
                    return(bs.apiFail("알 수 없는 에러 발생"));
                }
                else
                {
                    return(bs.apiFail((Dictionary <string, bs.ValiResult>)bs.s("valiError")));
                }
            }
            String errMsg = null;
            await bs.dbAsync(false, "remote", async (db) => {
                var pr = await db.selectAsync <int>("contents/tree/view", before);
                if (pr.noRecord)
                {
                    errMsg = "트리의 부모 정보를 가져오지 못했습니다.";
                    return(false);
                }
                before.Add("parent_rowid", pr.result);
                var rs = await db.execAsync("contents/tree/add", before);
                if (rs.result != 1)
                {
                    errMsg = "트리를 등록하는데 실패했습니다.";
                    return(false);
                }
                return(true);
            });

            if (errMsg != null)
            {
                return(bs.apiFail(errMsg));
            }
            return(bs.apiOk(new { success = 1 }));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> add()
        {
            var before = (Dictionary <string, object>)bs.before(this);

            if (null == before)
            {
                //return bs.beforeErr();
                if (null == bs.s("valiError"))
                {
                    return(bs.apiFail("알 수 없는 에러 발생"));
                }
                else
                {
                    return(bs.apiFail((Dictionary <string, bs.ValiResult>)bs.s("valiError")));
                }
            }
            Dictionary <String, String> teacher = null;
            int    teacher_rowid = 0;
            String errMsg        = null;
            await bs.dbAsync(true, "remote", async (db) => {
                var rs0 = await db.selectAsync <Dictionary <String, String> >("teacher/view_from_cmps_rowid", before);
                if (rs0.valiError)
                {
                    errMsg = "유효성 검사 오류";
                    return(false);
                }
                if (!rs0.noRecord)
                {
                    errMsg = "이미 존재하는 교수입니다.";
                    return(false);
                }

                var rs1 = await db.execAsync("teacher/add", before);
                if (rs1.result != 1)
                {
                    errMsg = "교수를 추가하지 못했습니다.";
                    return(false);
                }
                teacher_rowid = rs1.insertId;

                var rs2 = await db.selectAsync <Dictionary <String, String> >("teacher/view_from_rowid", "teacher_rowid", teacher_rowid + "");
                if (rs2.noRecord)
                {
                    errMsg = "교수 정보를 가져오지 못했습니다.";
                    return(false);
                }
                teacher = rs2.result;
                return(true);
            });

            if (errMsg != null)
            {
                return(bs.apiFail(errMsg));
            }
            return(bs.apiOk(new {
                success = 1,
                professor = new {
                    r = teacher["teacher_rowid"],
                    cmps_r = teacher["cmps_rowid"],
                    username = teacher["username"],
                    regdate = teacher["regdate"]
                }
            }));
        }