Ejemplo n.º 1
0
 public User GetUserById(int id)                     //Method to get details by id
 {
     using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
     {
         return(dbContext.User.Find(id));
     }
 }
Ejemplo n.º 2
0
 public void BlockUser(User user)                    // Method to block user
 {
     using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
     {
         dbContext.Entry(user).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public User CheckLoginDetails(string name, string password)     //Method to check signin details
 {
     using (TrainTicketBookingDbContext userDataBase = new TrainTicketBookingDbContext())
     {
         User user = userDataBase.User.Where(m => m.FirstName == name && m.Password == password).FirstOrDefault();
         return(user);
     }
 }
Ejemplo n.º 4
0
        public List <User> GetBlockedUserDetails()               //Method to get blocked user list
        {
            List <User> user = new List <User>();

            using (TrainTicketBookingDbContext userDataBase = new TrainTicketBookingDbContext())
            {
                user = userDataBase.User.Where(m => m.IsActive == false).ToList();
            }
            return(user);
        }
Ejemplo n.º 5
0
        public List <User> GetUserDetails()
        {
            List <User> user = new List <User>();

            using (TrainTicketBookingDbContext userDataBase = new TrainTicketBookingDbContext())
            {
                user = userDataBase.User.ToList();
            }
            return(user);
        }
Ejemplo n.º 6
0
        //protected static List<User> userList = new List<User>();        //A static user list to store user details
        //SqlConnection sqlConnection = DBUtils.GetDBConnection();
        //SqlConnection sqlConnection = Connectivity.EstablishConnection();
        //public int RegisterDetail(User user)            //Method to make user to register with the account
        //{
        //    using (SqlCommand sqlCommand = new SqlCommand("USER_ADMIN_Registration", sqlConnection))
        //    {
        //        sqlCommand.CommandType = CommandType.StoredProcedure;
        //        sqlConnection.Open();
        //        sqlCommand.Parameters.Add(new SqlParameter("@firstname", user.FirstName));
        //        sqlCommand.Parameters.Add(new SqlParameter("@lastname", user.LastName));
        //        sqlCommand.Parameters.Add(new SqlParameter("@age", user.Age));
        //        sqlCommand.Parameters.Add(new SqlParameter("@sex", user.Sex));
        //        sqlCommand.Parameters.Add(new SqlParameter("@email", user.Email));
        //        sqlCommand.Parameters.Add(new SqlParameter("@mobileno", user.MobileNum));
        //        sqlCommand.Parameters.Add(new SqlParameter("@password", user.Password));
        //        sqlCommand.Parameters.Add(new SqlParameter("@role", user.Status));
        //        int retRows = sqlCommand.ExecuteNonQuery();
        //        sqlCommand.Dispose();
        //        sqlConnection.Close();
        //        return retRows;
        //    }

        //}

        //public short VerifyWithDB(string userName, string passWord)
        //{

        //    using (SqlCommand sqlCommand = new SqlCommand("spCHECKDB", sqlConnection))
        //    {
        //        SqlParameter sqlParameter = new SqlParameter();
        //        sqlCommand.CommandType = CommandType.StoredProcedure;
        //        sqlCommand.Parameters.AddWithValue("@firstname", userName);
        //        sqlCommand.Parameters.AddWithValue("@password", passWord);
        //        sqlCommand.Parameters.Add("@id", SqlDbType.Int, 3);
        //        sqlCommand.Parameters["@id"].Direction = ParameterDirection.Output;
        //        sqlConnection.Open();
        //        sqlCommand.ExecuteNonQuery();
        //        short ID = Convert.ToInt16(sqlCommand.Parameters["@id"].Value);
        //        sqlConnection.Close();
        //        return ID;
        //    }
        //}

        //public string FetchRole(int ID)
        //{
        //    using (SqlCommand sqlCommand = new SqlCommand("spFETCHROLE", sqlConnection))
        //    {
        //        SqlParameter sqlParameter = new SqlParameter();
        //        sqlCommand.CommandType = CommandType.StoredProcedure;
        //        sqlCommand.Parameters.AddWithValue("@id", ID);
        //        sqlCommand.Parameters.Add("@role", SqlDbType.VarChar, 6);
        //        sqlCommand.Parameters["@role"].Direction = ParameterDirection.Output;
        //        sqlConnection.Open();
        //        sqlCommand.ExecuteNonQuery();
        //        string role = Convert.ToString(sqlCommand.Parameters["@role"].Value);
        //        sqlConnection.Close();
        //        return role;
        //    }
        //}


        //static List<User> userDetails = new List<User>();
        //static UserRepository()
        //{
        //    userDetails.Add(new User { FirstName = "Monika", LastName = "Kamaraj", Age = 21, Sex = "Female", Email = "*****@*****.**", MobileNum = 8807697440, Password = "******", Status = (Role) Enum.Parse(typeof(Role), "Admin", true)});
        //}



        public bool AddUserDetails(User user)           //Adding user details
        {
            try
            {
                using (TrainTicketBookingDbContext userDataBase = new TrainTicketBookingDbContext())
                {
                    userDataBase.User.Add(user);
                    userDataBase.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
 //public User GetUserByName(string name)                     //Method to get details by id
 //{
 //    using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
 //    {
 //        return dbContext.User.Find(name);
 //    }
 //}
 public bool UpdateProfile(User user)                    // Method to Update user
 {
     try
     {
         using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
         {
             dbContext.Entry(user).State = EntityState.Modified;
             dbContext.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }