Exemplo n.º 1
0
        //readonly string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\npartyko\Source\Repos\sammit\SummitService\SummitService\App_Data\SummitDB.mdf;Integrated Security=True";
        //readonly string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Юрий\Desktop\8 семестр\Проектирование ИСУ\репоз\SummitService\SummitService\App_Data\SummitDB.mdf;Integrated Security=True";
        public Auth Authorisation(string Login, string Password)
        {
            Auth auth = new Auth();

            if (FindByLoginUsers(Login, Password))
            {
                using (SummitDBEntity summit = new SummitDBEntity())
                {
                    User use = summit.Users
                               .Where(s => s.Login == Login)
                               .Where(p => p.Password == Password)
                               .FirstOrDefault();
                    if (use != null)
                    {
                        auth.error         = false;
                        auth.error_message = null;
                        auth.id_user       = use.ID_User;
                        return(auth);
                    }
                    else
                    {
                        auth.error         = true;
                        auth.error_message = "Неверное имя пользователя или пароль";
                        return(auth);
                    }
                }
            }
            else
            {
                auth.error         = true;
                auth.error_message = "Неверное имя пользователя или пароль";
                return(auth);
            }
        }
Exemplo n.º 2
0
 public List <Summit> SelectSummit()
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         List <Summit> su = summit.Summits.ToList();
         return(su);
     }
 }
Exemplo n.º 3
0
        /*public List<Voice> Summarizing()
         * {
         *  //string sqlExpression = "Summarizing";
         *  //using (SqlConnection connection = new SqlConnection(connectionString))
         *  using (SummitDBEntity summit = new SummitDBEntity())
         *  {
         *
         *      /*connection.Open();
         *      SqlCommand command = new SqlCommand(sqlExpression, connection)
         *      {
         *          CommandType = System.Data.CommandType.StoredProcedure
         *      };
         *
         *
         *      var reader = command.ExecuteReader();
         *
         *      List<Voice> summarizing = new List<Voice>();
         *      if (reader.HasRows)
         *      {
         *          while (reader.Read())
         *          {
         *              Voice cli = new Voice
         *              {
         *
         *                  variant_id = reader.GetInt32(0),
         *                  sum = reader.GetInt32(1),
         *                  country_name = reader.GetString(2),
         *                  start_date = reader.GetDateTime(3),
         *                  finish_date = reader.GetDateTime(4)
         *
         *              };
         *              summarizing.Add(cli);
         *          }
         *          return summarizing;
         *      }
         *      else
         *      {
         *          return null;
         *      }
         *
         *  }
         * }*/

        public List <Country> SelectCountry()
        {
            using (SummitDBEntity summit = new SummitDBEntity())
            {
                List <Country> co = summit.Countries.ToList();
                return(co);
            }
        }
Exemplo n.º 4
0
 public Country AddCountry(Country cou)
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         var count = summit.Countries
                     .Where(s => s.Name == cou.Name)
                     .Count();
         if (count == 0)
         {
             summit.Countries.Add(cou);
             summit.SaveChanges();
         }
     }
     return(cou);
 }
Exemplo n.º 5
0
        public Summit AddSummit(Summit sum)
        {
            using (SummitDBEntity summit = new SummitDBEntity())
            {
                var count = summit.Summits
                            .Where(s => s.Name == sum.Name)
                            .Count();
                if (count == 0)
                {
                    summit.Summits.Add(sum);
                    summit.SaveChanges();
                }
            }

            return(sum);
        }
Exemplo n.º 6
0
 public Voice AddVoice(Voice vo)
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         var count = summit.Voices
                     .Where(s => s.User_ID == vo.User_ID)
                     .Where(s => s.Variant_ID == vo.Variant_ID)
                     .Count();
         if (count == 0)
         {
             summit.Voices.Add(vo);
             summit.SaveChanges();
         }
         return(vo);
     }
 }
Exemplo n.º 7
0
 public Variant AddVariant(Variant va)
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         var count = summit.Variants
                     .Where(s => s.User_ID == va.User_ID)
                     .Where(s => s.Summit_ID == va.Summit_ID)
                     .Where(s => s.Country_ID == va.Country_ID)
                     .Count();
         if (count == 0)
         {
             summit.Variants.Add(va);
             summit.SaveChanges();
         }
         return(va);
     }
 }
Exemplo n.º 8
0
 public bool FindByLoginUsers(string Login, string Password)
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         User use = summit.Users
                    .Where(s => s.Login == Login)
                    .Where(p => p.Password == Password)
                    .FirstOrDefault();
         if (use != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 9
0
 public void DeleteAllVoices()
 {
     using (SummitDBEntity summit = new SummitDBEntity())
     {
         using (var transaction = summit.Database.BeginTransaction())
         {
             try
             {
                 foreach (var s in summit.Voices)
                 {
                     summit.Voices.Remove(s);
                 }
                 summit.SaveChanges();
                 transaction.Commit();
             }
             catch
             {
                 transaction.Rollback();
             }
         }
     }
 }