public bool AddAdward(Adward adward) { using (SqlConnection con = new SqlConnection(conStr)) { SqlCommand cmd = con.CreateCommand(); con.Open(); cmd.CommandText = "dbo.AddAward"; cmd.CommandType = System.Data.CommandType.StoredProcedure; var IdParam = new SqlParameter() { DbType = System.Data.DbType.Int32, ParameterName = "@Id", Value = adward.Id, Direction = System.Data.ParameterDirection.Output, }; var TitleParam = new SqlParameter() { DbType = System.Data.DbType.String, ParameterName = "@Title", Value = adward.Title, }; cmd.Parameters.Add(IdParam); cmd.Parameters.Add(TitleParam); cmd.ExecuteNonQuery(); } return(true); }
public Adward AddAdward(string Title) { Adward adward = new Adward { Id = _adwardDao.GetAll().Count() + 1, Title = Title }; if (_adwardDao.AddAdward(adward)) { return(adward); } throw new ArgumentException("Error on adward added"); }
public IEnumerable <Adward> GetAll() { using (SqlConnection con = new SqlConnection(conStr)) { SqlCommand cmd = con.CreateCommand(); con.Open(); cmd.CommandText = "dbo.GetAllAward"; cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlDataReader sqlDataReader = cmd.ExecuteReader(); User[] users = new User[] { }; while (sqlDataReader.Read()) { int Id = (int)sqlDataReader["Id"]; string Title = (string)sqlDataReader["Title"]; Adward award = new Adward { Id = Id, Title = Title }; yield return(award); } } }
public bool AddAdward(Adward adward) { _adwards.Add(_adwards.Keys.Count + 1, adward); Save(); return(true); }