public bool Create(KeyValuesViewModel data, out string errMsg)
        {
            KeyValuesDAO keyValuesDAO = new KeyValuesDAO();

            errMsg = "";

            try
            {
                KeyValues modelData = new KeyValues();

                modelData.KeyValueName = data.KeyValueName;
                modelData.Text         = data.Text;
                modelData.Value        = data.Value;
                modelData.Sort         = data.Sort;
                modelData.EnterPriseId = data.EnterPriseId;

                keyValuesDAO.Insert(modelData);
                keyValuesDAO.SaveChange();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }

            return(true);
        }
        public bool Update(KeyValuesViewModel data, out string errMsg)
        {
            KeyValuesDAO keyValuesDAO = new KeyValuesDAO();

            errMsg = "";

            try
            {
                var dbModel = keyValuesDAO.FindById(data.Id);

                dbModel.KeyValueName = data.KeyValueName;
                dbModel.Text         = data.Text;
                dbModel.Value        = data.Value;
                dbModel.Sort         = data.Sort;
                dbModel.EnterPriseId = data.EnterPriseId;

                keyValuesDAO.Update(dbModel);
                keyValuesDAO.SaveChange();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }

            return(true);
        }
        public bool Delete(KeyValuesViewModel data, out string errMsg)
        {
            KeyValuesDAO keyValuesDAO = new KeyValuesDAO();

            errMsg = "";

            try
            {
                var dbModel = keyValuesDAO.FindById(data.Id);

                keyValuesDAO.Delete(dbModel);
                keyValuesDAO.SaveChange();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }

            return(true);
        }