Пример #1
0
        private string getAJAXparams(FunAndSP fun_and_sp)
        {
            List <string> aJAX_Params = new List <string>();

            if (!string.IsNullOrWhiteSpace(fun_and_sp.Name))
            {
                aJAX_Params.Add("Name=" + fun_and_sp.Name);
            }
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Execute))
            {
                aJAX_Params.Add("Execute=" + fun_and_sp.Execute);
            }
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Content))
            {
                aJAX_Params.Add("Content=" + fun_and_sp.Content);
            }
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Remark))
            {
                aJAX_Params.Add("Remark=" + fun_and_sp.Remark);
            }
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Tags))
            {
                aJAX_Params.Add("Tags=" + fun_and_sp.Tags);
            }

            if (aJAX_Params.Count > 0)
            {
                return("/search?" + string.Join("&", aJAX_Params));
            }
            else
            {
                return("");
            }
        }
Пример #2
0
        public ActionResult TableInfo(FunAndSP fun_and_sp)
        {
            ViewBag.Title = "Home Page";

            ViewBag.Name = "";
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Name))
            {
                ViewBag.Name = fun_and_sp.Name;
            }
            ViewBag.EXECUTE = "";
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Execute))
            {
                ViewBag.EXECUTE = fun_and_sp.Execute;
            }
            ViewBag.content = "";
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Content))
            {
                ViewBag.content = fun_and_sp.Content;
            }
            ViewBag.remark = "";
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Remark))
            {
                ViewBag.remark = fun_and_sp.Remark;
            }
            ViewBag.tags = "";
            if (!string.IsNullOrWhiteSpace(fun_and_sp.Tags))
            {
                ViewBag.tags = fun_and_sp.Tags;
            }

            ViewBag.AJAXparams = getAJAXparams(fun_and_sp);

            return(View());
        }
Пример #3
0
        /// <summary>
        /// Create
        /// </summary>
        /// <param name="fun_and_sp"></param>
        /// <returns>回傳新增的資料</returns>
        public IHttpActionResult PostAdd(FunAndSP fun_and_sp)
        {
            DateTime dNow = DateTime.Now;

            fun_and_sp.CreatedTime = dNow;
            fun_and_sp.UpdateTime  = dNow;

            Exception exception = null;

            try
            {
                using (SQL_Programmability db = new SQL_Programmability())
                {
                    db.FunAndSP.Add(fun_and_sp);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                exception = ex;
                return(NotFound());
            }

            if (exception == null)
            {
                return(Created(Url.Link("DefaultApi", new { id = fun_and_sp.Id }), fun_and_sp));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #4
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="fun_and_sp"></param>
        /// <returns>回傳修改的資料</returns>
        public IHttpActionResult PutEdit(FunAndSP fun_and_sp)
        {
            DateTime dNow = DateTime.Now;

            FunAndSP  new_fun_and_sp = new FunAndSP();
            Exception exception      = null;

            try
            {
                using (SQL_Programmability db = new SQL_Programmability())
                {
                    new_fun_and_sp = db.FunAndSP.Find(fun_and_sp.Id);
                    if (new_fun_and_sp != null)
                    {
                        new_fun_and_sp.Name       = fun_and_sp.Name;
                        new_fun_and_sp.Execute    = fun_and_sp.Execute;
                        new_fun_and_sp.Content    = fun_and_sp.Content;
                        new_fun_and_sp.Remark     = fun_and_sp.Remark;
                        new_fun_and_sp.Tags       = fun_and_sp.Tags;
                        new_fun_and_sp.UpdateTime = dNow;
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                exception = ex;
                return(NotFound());
            }

            if (exception == null && new_fun_and_sp != null)
            {
                return(Created(Url.Link("DefaultApi", new { id = new_fun_and_sp.Id }), new_fun_and_sp));
            }
            else
            {
                return(NotFound());
            }
        }