示例#1
0
 public static SmScenario Build(string name, int week, int scenarioMask, int scenarioWeekMin,
                                int scenarioWeekMax, int markdownCountStartWeek, int defaultMarkdownType,
                                DecisionState defaultDecisionState, bool allowPromoAsMarkdown, decimal minimumPromoPercentage,
                                int organisationId, int userId)
 {
     return(new SmScenario
     {
         ScenarioId = 0,
         Week = week,
         ScheduleWeekMin = scenarioWeekMin,
         ScheduleWeekMax = scenarioWeekMax,
         ScheduleStageMin = 1,
         ScheduleStageMax = 4,
         OrganisationId = organisationId,
         ScenarioName = name,
         ScheduleMask = scenarioMask,
         MarkdownCountStartWeek = markdownCountStartWeek,
         DefaultMarkdownType = defaultMarkdownType,
         DefaultDecisionState = defaultDecisionState,
         DefaultDecisionStateName = defaultDecisionState.ToString(),
         AllowPromoAsMarkdown = allowPromoAsMarkdown,
         MinimumPromoPercentage = minimumPromoPercentage,
         CreatedBy = userId
     });
 }
        public async Task SetDecisionState(int clientId, int scenarioId, int productId, DecisionState state)
        {
            var entity = await Context.RecommendationProduct.SingleAsync(x => x.ClientId == clientId && x.ScenarioId == x.ScenarioId && x.ProductId == productId);

            entity.DecisionStateName = state.ToString();
            Context.RecommendationProduct.Update(entity);
            await Context.SaveChangesAsync();
        }
 public async Task <int> SetDecisionState(int clientId, int scenarioId, DecisionState state)
 {
     using (var command = new NpgsqlCommand(
                @"UPDATE recommendation_product
           SET decision_state_name = @p_state
           WHERE client_id = @p_client_id AND scenario_id = @p_scenario_id",
                (NpgsqlConnection)Context.Connection))
     {
         command.Parameters.AddWithValue("p_client_id", NpgsqlDbType.Integer, clientId);
         command.Parameters.AddWithValue("p_scenario_id", NpgsqlDbType.Integer, scenarioId);
         command.Parameters.AddWithValue("p_state", NpgsqlDbType.Varchar, state.ToString());
         return(await command.ExecuteNonQueryAsync());
     }
 }
示例#4
0
 // TODO remove this in favour of log structure
 public async Task <int> CreateOrUpdate(int?week, int scheduleWeekMin, int scheduleWeekMax, int scheduleStageMin, int scheduleStageMax, int?stageMax,
                                        int?stageOffsetMax, decimal?priceFloor, int organisationId, int createdBy, string scenarioName, int scheduleMask, int markdownCountStartWeek, int defaultMarkdownType, DecisionState defaultDecisionState)
 {
     return(await Context.Connection.QuerySingleAsync <int>(
                @"INSERT INTO scenario (week, schedule_week_min, schedule_week_max, schedule_stage_min, schedule_stage_max, stage_max, stage_offset_max, price_floor, organisation_id, created_by, scenario_name, schedule_mask, markdown_count_start_week, default_markdown_type, default_decision_state_name)
             VALUES (@Week, @ScheduleWeekMin, @ScheduleWeekMax, @ScheduleStageMin, @ScheduleStageMax, @StageMax, @StageOffsetMax, @PriceFloor, @OrganisationId,@CreatedBy, @ScenarioName, @ScheduleMask, @MarkdownCountStartWeek, @DefaultMarkdownType, @DefaultDecisionStateName)
             ON CONFLICT (scenario_id) DO UPDATE 
             SET week = @Week,
                 schedule_week_min = @ScheduleWeekMin,
                 schedule_week_max = @ScheduleWeekMax,
                 schedule_stage_min = @ScheduleStageMin,
                 schedule_stage_max = @ScheduleStageMax,
                 stage_max = @StageMax,
                 stage_offset_max = @StageOffsetMax,
                 price_floor = @PriceFloor,      
                 organisation_Id = @OrganisationId,
                 created_by = @CreatedBy,
                 scenario_name = @ScenarioName,
                 schedule_mask = @ScheduleMask,
                 markdown_count_start_week = @MarkdownCountStartWeek,
                 default_markdown_type = @DefaultMarkdownType,
                 default_decision_state_name = @DefaultDecisionStateName
             RETURNING scenario_id",
                new
     {
         Week = week,
         ScheduleWeekMin = scheduleWeekMin,
         ScheduleWeekMax = scheduleWeekMax,
         ScheduleStageMin = scheduleStageMin,
         ScheduleStageMax = scheduleStageMax,
         StageMax = stageMax,
         StageOffsetMax = stageOffsetMax,
         PriceFloor = priceFloor,
         OrganisationId = organisationId,
         CreatedBy = createdBy,
         ScenarioName = scenarioName,
         ScheduleMask = scheduleMask,
         MarkdownCountStartWeek = markdownCountStartWeek,
         DefaultMarkdownType = defaultMarkdownType,
         DefaultDecisionStateName = defaultDecisionState.ToString()
     }));
 }