Example #1
0
        public static int Create(OrderTypeDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("OrderType.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Example #2
0
        public static string Save(OrderTypeDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            FormatData(data);

            switch (action)
            {
            case "Create":
                sql += "dbo.OrderTypeInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.OrderTypeUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, OrderTypeDataModel.DataColumns.OrderTypeId);
            sql = sql + ", " + ToSQLParameter(data, OrderTypeDataModel.DataColumns.Code);
            sql = sql + ", " + ToSQLParameter(data, OrderTypeDataModel.DataColumns.Description);

            return(sql);
        }
Example #3
0
        public static bool DoesExist(OrderTypeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new OrderTypeDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Example #4
0
        public static void Delete(OrderTypeDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.OrderTypeDelete ";

            var parameters =
                new
            {
                AuditId       = requestProfile.AuditId
                , OrderTypeId = data.OrderTypeId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Example #5
0
        public static string ToSQLParameter(OrderTypeDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case OrderTypeDataModel.DataColumns.OrderTypeId:
                if (data.OrderTypeId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, OrderTypeDataModel.DataColumns.OrderTypeId, data.OrderTypeId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, OrderTypeDataModel.DataColumns.OrderTypeId);
                }
                break;

            case OrderTypeDataModel.DataColumns.Code:
                if (!string.IsNullOrEmpty(data.Code))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, OrderTypeDataModel.DataColumns.Code, data.Code);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, OrderTypeDataModel.DataColumns.Code);
                }
                break;

            case OrderTypeDataModel.DataColumns.Description:
                if (!string.IsNullOrEmpty(data.Description))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, OrderTypeDataModel.DataColumns.Description, data.Description);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, OrderTypeDataModel.DataColumns.Description);
                }
                break;


            default:
                returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Example #6
0
        public static List <OrderTypeDataModel> GetEntityDetails(OrderTypeDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.OrderTypeSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ReturnAuditInfo = returnAuditInfo
                , OrderTypeId     = dataQuery.OrderTypeId
                , Code            = dataQuery.Code
            };

            List <OrderTypeDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <OrderTypeDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Example #7
0
        public static void Update(OrderTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("OrderType.Update", sql, DataStoreKey);
        }
Example #8
0
 public static void FormatData(OrderTypeDataModel data)
 {
     data.Code = Formatter.FormatCode(data.Code);
 }
Example #9
0
        public static DataTable Search(OrderTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }