public ActionResult Create(ColorInfo color) { if (ModelState.IsValid) { mt = mt.Load(); mt.oColor.Add(color); mt.Save("addcolor"); return RedirectToAction("Index"); } return View(color); }
public ActionResult Index() { ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; MainStructure mt = new MainStructure(); try { mt.Load(); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#0094ff;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#b6ff00;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#b6ff00;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#08bdf8;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#f3bf18;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#f784d8;" }); mt.oColor.Add(new ColorInfo() { Name = "", Code = "#08bdf8;" }); ViewBag.conme = Current.DataFolder(); mt.Save("add colors"); } catch(Exception ex) { ViewBag.errorms = ex.Message; } return View(); }