private void btnLinkAdd_Click(object sender, EventArgs e) { _resortLinkService = new ResortLinkService(_resortLinkRepository); var link = new ResortLink { Name = NewLinkName.Text, URL = NewUrl.Text, ResortID = _resort.ID }; _resortLinkService.Add(link); GetResort(); }
private void btnLinkSave_Click(object sender, EventArgs e) { _resortLinkService = new ResortLinkService(_resortLinkRepository); var link = new ResortLink { ID = int.Parse(LinkId.Text), Name = LinkName.Text, URL = Url.Text, ResortID = _resort.ID }; _resortLinkService.Update(link); GetResort(); }
public static int AddResortLink(ResortLink resortLink) { //TODO: put all this in a method SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQL2005_615410_sporthubConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand("AddResortLink", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Name", resortLink.Name)); cmd.Parameters.Add(new SqlParameter("@ResortID", resortLink.ResortID)); cmd.Parameters.Add(new SqlParameter("@ResortLinkTypeID", resortLink.ResortLinkTypeID)); cmd.Parameters.Add(new SqlParameter("@URL", resortLink.URL)); cmd.Parameters.Add(new SqlParameter("@Sequence", resortLink.Sequence)); cmd.Parameters.Add(new SqlParameter("@CreatedUserID", resortLink.CreatedUserID)); cmd.Parameters.Add(new SqlParameter("@UpdatedUserID", resortLink.UpdatedUserID)); conn.Open(); string resortLinkID = cmd.ExecuteScalar().ToString(); return int.Parse(resortLinkID); }