Beispiel #1
0
        public ActionResult Create(HomePage item)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                if (string.IsNullOrEmpty(item.entryname) || string.IsNullOrEmpty(item.entrycode))
                {
                    return(Json(new { success = false, message = tw_Lang.Common_ActionResult_MissingInfo }));
                }
                var isExist = HomePage.GetById(item.entryid, null, false);

                //Validate

                //insert / update
                if (item.entryid == 0)
                {
                    //insert
                    item.createdat = DateTime.Now;
                    item.createdby = currentUser.entryid;
                    item.updatedat = DateTime.Now;
                    item.updatedby = currentUser.entryid;
                    item.isactive  = true;
                }
                else
                {
                    //update
                    item.createdby = isExist.createdby;
                    item.updatedat = DateTime.Now;
                    item.updatedby = currentUser.entryid;
                }
                item.AddOrUpdate(currentUser.entryid, null, false);
                return(Json(new { success = true, data = item }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { db.Close(); }
        }