Beispiel #1
0
        public Answard GetByID(int ID)
        {
            Answard user = new Answard();

            using (var connection = new SqlConnection(_connectionString))
            {
                var cmd = connection.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetAnswardByID";
                cmd.Parameters.AddWithValue(@"ID", ID);
                connection.Open();
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    user.ID = (int)reader["ID"];
                }
            }
            return(user);
        }
Beispiel #2
0
 public void Add(Answard value)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         var cmd = connection.CreateCommand();
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "AddAnsward";
         cmd.Parameters.AddWithValue(@"ID_user", value.ID_user);
         cmd.Parameters.AddWithValue(@"Title", value.Title);
         var id = new SqlParameter
         {
             DbType        = DbType.Int32,
             ParameterName = "@ID",
             Direction     = ParameterDirection.Output
         };
         cmd.Parameters.Add(id);
         connection.Open();
         cmd.ExecuteNonQuery();
     }
 }
Beispiel #3
0
        public static void AnswardProfile(Answard answard)
        {
            Console.Clear();
            Console.WriteLine(answard);
            Console.WriteLine("1.Изменить название \n2.Удалить  \n0.Назад");
            switch (Console.ReadLine())
            {
            case "1":
                Console.Clear();
                Console.WriteLine("Введите новое название: ");
                string title = Console.ReadLine();
                answardLogic.UpdateAnsward(answard.ID, title);
                answard.Title = title;
                AnswardProfile(answard);
                break;

            case "2":
                Console.WriteLine("Удалить достижение?");
                switch (Console.ReadLine())
                {
                case "Да":
                    answardLogic.Remove(answard.ID);
                    Answards();
                    break;

                case "Нет":
                    AnswardProfile(answard);
                    break;
                }
                break;

            case "0":
                Answards();
                break;
            }
        }
 public void Add(Answard value)
 {
     answardDao.Add(value);
 }