Exemple #1
0
        public async Task <ActionResult> SaveToDynamo(int carsBatchSize = 2)
        {
            try
            {
                // This whole process only happens once to initialize the database
                IEnumerable <BrandDTO> brands = (await publicRepository.GetBrandList()).Take(carsBatchSize * 10).ToList();

                foreach (BrandDTO b in brands)
                {
                    b.models = (await publicRepository.GetModelListsByBrandId(b.Id)).Take(carsBatchSize).ToList();

                    foreach (ModelDTO m in b.models)
                    {
                        await carRepository.AddBulk((await publicRepository.GetCarsList(b.Id, m.Id)).Take(carsBatchSize).ToList());
                    }
                }

                return(Ok());
            } catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new Error {
                    Message = e.Message
                }));
            }
        }