public ActionResult AddFoodToCSV(AddFoodToCSVViewModel viewModel) { string newFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\TabeleKaloryczne.csv"); string FoodToInsert = Environment.NewLine + viewModel.FoodModel.Name + "." + viewModel.FoodModel.Calories + "." + viewModel.FoodModel.Protein + "." + viewModel.FoodModel.Fat + "." + viewModel.FoodModel.Carbohydrates; System.IO.File.AppendAllText(newFileName, FoodToInsert); return(Redirect(viewModel.Url)); }
public ActionResult AddFoodToCSV() { var viewModel = new AddFoodToCSVViewModel(); viewModel.FoodModel = new FoodModel(); viewModel.Url = Request.UrlReferrer.ToString(); return(View(viewModel)); }