//not if this returns something, since it creates a new file in the DataFiles folder public void CreateFile(string dateToday) { var repo = new OrderRepository(); //var response = new Response<string>(); //try //{ var orderFilePath = repo.CreateFilePath(dateToday); //FileStream fs = File.Create(orderFilePath); if (!File.Exists(orderFilePath)) { /*Do what we need to do to create a new file*/ using (StreamWriter sw = File.CreateText(orderFilePath)) { sw.WriteLine("OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LborCostPerSquareFoot,MaterialCost,TotalTax,Total"); sw.Close(); } } //using (var writer = File.CreateText(orderFilePath)) //{ // writer.WriteLine("OrderNumber,CustomerName,State,TaxRate,ProductType,Area,CostPerSquareFoot,LborCostPerSquareFoot,MaterialCost,TotalTax,Total"); //} //} // else // { // /*we open that file and write a new order onto that*/ // } //catch (Exception ) // { // } //} }
public void CanCreateFilePath() { var repo = new OrderRepository(); var fileName = repo.CreateFilePath("01012015"); Assert.AreEqual(@"DataFiles\Orders_01012015.txt", fileName); }
public Response<string> GetFile(string filePathWithDate) { var repo = new OrderRepository(); //not 100% sure what type of response is needed var response = new Response<string>(); try { var orderFilePath = repo.CreateFilePath(filePathWithDate); if (!File.Exists(orderFilePath)) { response.Success = false; response.Message = "Order date not found"; } else { response.Success = true; response.Data = orderFilePath; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return response; }