public static DataTypeView MapEntityToView(DataType dt)
        {
            DataTypeView dtv = new DataTypeView();

             dtv.FldKey = dt.FldKey;
             dtv.FldBigInt = dt.FldBigInt.ToString();
             dtv.FldBit = dt.FldBit.ToString();
             dtv.FldChar = dt.FldChar.Trim();
             dtv.FldDateTime = dt.FldDateTime.ToString();
             dtv.FldDecimal = dt.FldDecimal.ToString();
             dtv.FldInt = dt.FldInt.ToString();
             dtv.FldMoney = dt.FldMoney.ToString();
             dtv.FldNChar = dt.FldNChar.Trim();
             dtv.FldNText = dt.FldNText.Trim();
             dtv.FldNumeric = dt.FldNumeric.ToString();
             dtv.FldNVarChar = dt.FldNVarChar.Trim();
             dtv.FldNVarCharMax = dt.FldNVarCharMax.Trim();
             dtv.FldSmallDateTime = dt.FldSmallDateTime.ToString();
             dtv.FldSmallInt = dt.FldSmallInt.ToString();
             dtv.FldSmallMoney = dt.FldSmallMoney.ToString();
             dtv.FldText = dt.FldText.Trim();
             dtv.FldTinyInt = dt.FldTinyInt.ToString();
             dtv.FldVarChar = dt.FldVarChar.Trim();
             dtv.FldVarCharMax = dt.FldVarCharMax.Trim();

             return dtv;
        }
        public static DataType MapViewToEntity(DataTypeView dtv)
        {
            DataType dt = new DataType();

             dt.FldKey = dtv.FldKey;
             dt.FldBigInt = Convert.ToInt64(dtv.FldBigInt);
             dt.FldBit = Boolean.Parse(dtv.FldBit);
             dt.FldChar = dtv.FldChar;
             dt.FldDateTime = Convert.ToDateTime(dtv.FldDateTime);
             dt.FldDecimal = Convert.ToDecimal(dtv.FldDecimal);
             dt.FldInt = Convert.ToInt32(dtv.FldInt);
             dt.FldMoney = Convert.ToDecimal(dtv.FldMoney);
             dt.FldNChar = dtv.FldNChar;
             dt.FldNText = dtv.FldNText;
             dt.FldNumeric = Convert.ToDecimal(dtv.FldNumeric);
             dt.FldNVarChar = dtv.FldNVarChar;
             dt.FldNVarCharMax = dtv.FldNVarCharMax;
             dt.FldSmallDateTime = Convert.ToDateTime(dtv.FldSmallDateTime);
             dt.FldSmallInt = Convert.ToInt16(dtv.FldSmallInt);
             dt.FldSmallMoney = Convert.ToDecimal(dtv.FldSmallMoney);
             dt.FldText = dtv.FldText;
             dt.FldTinyInt = Convert.ToByte(dtv.FldTinyInt);
             dt.FldVarChar = dtv.FldVarChar;
             dt.FldVarCharMax = dtv.FldVarCharMax;

             return dt;
        }
        public int SaveDataType(string FldKey, DataType addDataType)
        {
            int result = 0;

             DataTypesBusinessEntities.DataTypeView dtv = new DataTypesBusinessEntities.DataTypeView();
             dtv.FldKey = addDataType.FldKey;
             dtv.FldBigInt = addDataType.FldBigInt.Trim();
             dtv.FldBit = addDataType.FldBit.Trim();
             dtv.FldChar = addDataType.FldChar.Trim();
             dtv.FldDateTime = addDataType.FldDateTime.Trim();
             dtv.FldDecimal = addDataType.FldDecimal.Trim();
             dtv.FldInt = addDataType.FldInt.Trim();
             dtv.FldMoney = addDataType.FldMoney.Trim();
             dtv.FldNChar = addDataType.FldNChar.Trim();
             dtv.FldNText = addDataType.FldNText.Trim();
             dtv.FldNumeric = addDataType.FldNumeric.Trim();
             dtv.FldNVarChar = addDataType.FldNVarChar.Trim();
             dtv.FldNVarCharMax = addDataType.FldNVarCharMax.Trim();
             dtv.FldSmallDateTime = addDataType.FldSmallDateTime.Trim();
             dtv.FldSmallInt = addDataType.FldSmallInt.Trim();
             dtv.FldSmallMoney = addDataType.FldSmallMoney.Trim();
             dtv.FldText = addDataType.FldText.Trim();
             dtv.FldTinyInt = addDataType.FldTinyInt.Trim();
             dtv.FldVarChar = addDataType.FldVarChar.Trim();
             dtv.FldVarCharMax = addDataType.FldVarCharMax.Trim();
             result = _dataTypesService.SaveDataType(dtv);

             return result;
        }
Beispiel #4
0
        public int SaveDataType(string FldKey, DataType addDataType)
        {
            int result = 0;

            DataTypesBusinessEntities.DataTypeView dtv = new DataTypesBusinessEntities.DataTypeView();
            dtv.FldKey           = addDataType.FldKey;
            dtv.FldBigInt        = addDataType.FldBigInt.Trim();
            dtv.FldBit           = addDataType.FldBit.Trim();
            dtv.FldChar          = addDataType.FldChar.Trim();
            dtv.FldDateTime      = addDataType.FldDateTime.Trim();
            dtv.FldDecimal       = addDataType.FldDecimal.Trim();
            dtv.FldInt           = addDataType.FldInt.Trim();
            dtv.FldMoney         = addDataType.FldMoney.Trim();
            dtv.FldNChar         = addDataType.FldNChar.Trim();
            dtv.FldNText         = addDataType.FldNText.Trim();
            dtv.FldNumeric       = addDataType.FldNumeric.Trim();
            dtv.FldNVarChar      = addDataType.FldNVarChar.Trim();
            dtv.FldNVarCharMax   = addDataType.FldNVarCharMax.Trim();
            dtv.FldSmallDateTime = addDataType.FldSmallDateTime.Trim();
            dtv.FldSmallInt      = addDataType.FldSmallInt.Trim();
            dtv.FldSmallMoney    = addDataType.FldSmallMoney.Trim();
            dtv.FldText          = addDataType.FldText.Trim();
            dtv.FldTinyInt       = addDataType.FldTinyInt.Trim();
            dtv.FldVarChar       = addDataType.FldVarChar.Trim();
            dtv.FldVarCharMax    = addDataType.FldVarCharMax.Trim();
            result = _dataTypesService.SaveDataType(dtv);

            return(result);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="FldKey"></param>
        /// <returns></returns>
        public DataTypeView GetDataTypeView(int FldKey)
        {
            DataTypeView dataTypeView = new DataTypeView();

             DataType dataType = _repository.GetDataType(FldKey);
             dataTypeView = DataTypesMapper.MapEntityToView(dataType);

             return dataTypeView;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dtv"></param>
        /// <returns></returns>
        public int SaveDataType(DataTypeView dtv)
        {
            int result = 0;

             // Validation
             this.Errors.Clear();

             try
             {
            // Data access
            if (!this.HasErrors)
            {
               // Save
               DataType entity =  DataTypesMapper.MapViewToEntity(dtv);
               result = this._repository.SetDataType(entity);
            }
             }
             catch (System.Data.UpdateException ex)
             {
            if (ex.InnerException != null && ex.InnerException is System.Data.SqlClient.SqlException
               && ((System.Data.SqlClient.SqlException)ex.InnerException).ErrorCode == 8152)
               Errors.Add(ResourceStrings.ErrorMaxLength);
            else
               Errors.Add(ex.Message);
             }

             return result;
        }
 private void AddViewToList(DataTypeView dtv, ref DataTypeList list)
 {
     // Map DataTypeView to DataType and add to DataTypeList
      list.Add(new DataType()
      {
     FldKey = dtv.FldKey,
     FldBigInt = dtv.FldBigInt.Trim(),
     FldBit = dtv.FldBit.Trim(),
     FldChar = dtv.FldChar.Trim(),
     FldDateTime = dtv.FldDateTime.Trim(),
     FldDecimal = dtv.FldDecimal.Trim(),
     FldInt = dtv.FldInt.Trim(),
     FldMoney = dtv.FldMoney.Trim(),
     FldNChar = dtv.FldNChar.Trim(),
     FldNText = dtv.FldNText.Trim(),
     FldNumeric = dtv.FldNumeric.Trim(),
     FldNVarChar = dtv.FldNVarChar.Trim(),
     FldNVarCharMax = dtv.FldNVarCharMax.Trim(),
     FldSmallDateTime = dtv.FldSmallDateTime.Trim(),
     FldSmallInt = dtv.FldSmallInt.Trim(),
     FldSmallMoney = dtv.FldSmallMoney.Trim(),
     FldText = dtv.FldText.Trim(),
     FldTinyInt = dtv.FldTinyInt.Trim(),
     FldVarChar = dtv.FldVarChar.Trim(),
     FldVarCharMax = dtv.FldVarCharMax.Trim()
      });
 }