public ActionResult Create(Application app) { try { if (app != null) { _repo.AddTarget(app); } return RedirectToAction("GetTargets"); } catch { return View(); } }
public void AddTarget(Application app) { using (IDbConnection cn = Connection) { cn.Open(); const string query = "INSERT INTO [dbo].[Application]([Name],[Address],[Address2],[Timeout],[Interval]) VALUES (@Name,@Address,@Address2,@Timeout,@Interval)"; cn.Execute(query, new { Name = app.Name, Address = app.Address, Address2 = app.Address2, Timeout = app.Timeout, Interval = app.Interval }); cn.Close(); } }