public IActionResult GetCodes([FromRoute] int id, [FromQuery] int page) { var sql = new SQL(connectionString: _config.GetConnectionString("Storage")); var file = new CloudReader(filePath: _config.GetSection("File")["SeedBlobUrl"]); var pageSize = Convert.ToInt32(_config.GetSection("Pagination")["PageNumber"]); var alphabet = _config.GetSection("Base26")["Alphabet"]; var codes = sql.GetCodes(id, page, pageSize, alphabet); var pages = sql.PageCount(id); return(Ok(new TableData(codes, pages, page))); }
public IActionResult CreateBatch([FromBody] CreateCampaignRequest request) { if (request.CodesNumber >= 1 && request.CodesNumber <= 3000) { var sql = new SQL(connectionString: _config.GetConnectionString("Storage")); var file = new CloudReader(filePath: _config.GetSection("File")["SeedBlobUrl"]); var promotion = new Promotion() { Name = request.Name, BatchSize = request.CodesNumber }; var firstAndLastOffset = sql.UpdateOffset(promotion.BatchSize); var codes = file.GenerateCodes(firstAndLastOffset); sql.CreateBatch(promotion, codes); return(Ok(promotion)); } return(BadRequest()); }