コード例 #1
0
        public ActionResult UpdateActiveStatus(int entryid, bool isactive)
        {
            IDbConnection db = new OrmliteConnection().openConn();

            try
            {
                var isExist = AuthUser.GetById(entryid, null, false);
                isExist.isactive  = isactive;
                isExist.updatedby = currentUser.entryid;
                isExist.updatedat = DateTime.Now;
                db.UpdateOnly(isExist,
                              onlyFields: p =>
                              new
                {
                    p.isactive,
                    p.updatedat,
                    p.updatedby
                },
                              where : p => p.entryid == entryid);
                return(Json(new { success = true }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { db.Close(); }
        }
コード例 #2
0
        public ActionResult GetByID(int entryid)
        {
            IDbConnection dbConn = new OrmliteConnection().openConn();

            try
            {
                var data      = AuthUser.GetById(entryid);
                var ref_Roles = CustomModel.GetActiveStatus();

                var data_images_common = new List <ImgUploadModel>();
                if (!string.IsNullOrEmpty(data.avatarpath))
                {
                    data_images_common.Add(new ImgUploadModel()
                    {
                        key = 0, value = data.avatarpath
                    });
                }

                return(Json(new
                {
                    success = true,
                    data = data
                    ,
                    ref_Roles = ref_Roles
                    ,

                    data_images_common = data_images_common
                }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { dbConn.Close(); }
        }
コード例 #3
0
        public ActionResult EditProfile(AuthUser item, string imguploads)
        {
            IDbConnection db             = new OrmliteConnection().openConn();
            var           lst_ImgUploads = new List <ImgUploadModel>();

            //if (!string.IsNullOrEmpty(ImgUploads))
            //{
            //    lst_ImgUploads = (List<ImgUploadModel>)Newtonsoft.Json.JsonConvert.DeserializeObject(ImgUploads, typeof(List<ImgUploadModel>), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
            //}
            try
            {
                var isExist = AuthUser.GetById(item.entryid);


                item.password  = isExist.password;
                item.createdat = isExist.createdat;
                item.createdby = isExist.createdby;
                item.updatedat = DateTime.Now;
                item.updatedby = currentUser.entryid;
                item.AddOrUpdate(currentUser.entryid);

                return(Json(new { success = true }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
        }
コード例 #4
0
        public ActionResult Create(AuthUser 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 = AuthUser.GetById(item.entryid, null, false);

                //Validate

                //insert / update
                if (item.entryid == 0)
                {
                    //insert

                    item.entrycode = item.entryname;
                    item.logintype = (int)LoginType.Admin;
                    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(); }
        }
コード例 #5
0
        public ActionResult GetByID(int entryid)
        {
            IDbConnection dbConn = new OrmliteConnection().openConn();

            try
            {
                var data      = AuthUser.GetById(entryid, null, false);
                var ref_Roles = CustomModel.GetActiveStatus();
                return(Json(new
                {
                    success = true,
                    data = data
                }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
            finally { dbConn.Close(); }
        }