public async Task <IActionResult> Upload([FromForm] IFormFile file)
        {
            if (!file.FileName.EndsWith(".tsv"))
            {
                throw new ArgumentNullException("file", "Unsupported file type. The endpoint supports just *.tsv files");
            }

            await using (Stream sr = file.OpenReadStream())
            {
                var buffer = new byte[file.Length];

                await sr.ReadAsync(buffer, 0, (int)file.Length);

                var array = Encoding.UTF8.GetString(buffer).Split('\r');

                var columnArray = array[0].Split('\t');

                int nameIndex;
                int quantityIndex;

                if (columnArray[0].ToLower() == "name")
                {
                    nameIndex     = 0;
                    quantityIndex = 1;
                }
                else
                {
                    nameIndex     = 1;
                    quantityIndex = 0;
                }

                for (var i = 1; i < array.Length; i++)
                {
                    var row = array[i].Split('\t');

                    var brandName     = row[nameIndex];
                    var brandQuantity = Int32.Parse(row[quantityIndex]);

                    var brand = await brandRepository.FindByNameAsync(brandName);

                    if (brand == null)
                    {
                        brand = new Brand
                        {
                            Name = brandName
                        };
                        brandRepository.Add(brand);
                    }

                    var brandQuantityTimeReceived = new BrandQuantityTimeReceived
                    {
                        Brand        = brand,
                        Quantity     = brandQuantity,
                        TimeReseived = DateTime.Now
                    };
                    brandQuantityTimeReceivedRepository.Add(brandQuantityTimeReceived);
                }

                await brandQuantityTimeReceivedRepository.SaveAsync();
            }

            return(Ok());
        }
 /// <summary>
 /// Add a new record to brand quantity change log
 /// </summary>
 /// <param name="brandQuantitieTimeReceived"></param>
 public void Add(BrandQuantityTimeReceived brandQuantitieTimeReceived)
 {
     context.BrandQuantitiesTimeReceived.Add(brandQuantitieTimeReceived);
 }