//Grabs all rows from the contacts database
        public static List <ContactModel> LoadContacts()
        {
            //create sql statement to get all info from the contacts database
            string sql = @"select Id, FirstName, LastName, Company, Phone, Email
                           from dbo.ContactTable";

            //executes the sql statement and returns the number of rows affected
            return(SqlDataAccess.LoadData <ContactModel>(sql));
        }
Пример #2
0
        public static List <DataLibrary.Models.TaskModel> LoadTasks(int Id)
        {
            TaskModel data = new TaskModel
            {
                UserId = Id
            };
            string sql = "select * from dbo.Tasks where UserId=@UserId";

            return(SqlDataAccess.LoadData <DataLibrary.Models.TaskModel>(sql, data));
        }
        public static AccountModel SearchPropertyManager(string propertyCode)
        {
            string sql = "SELECT * from dbo.Account WHERE PropertyCode = '" + propertyCode + "' AND Tenant = 0;";
            List <AccountModel> model = SqlDataAccess.LoadData <AccountModel>(sql);

            if (model.Count == 0)
            {
                return(null);
            }
            return(model.First());
        }
        public static AccountModel SearchAccount(string email)
        {
            string sql = "SELECT * from dbo.Account WHERE EmailAddress = '" + email + "';";
            List <AccountModel> model = SqlDataAccess.LoadData <AccountModel>(sql);

            if (model.Count == 0)
            {
                return(null);
            }
            return(model.First());
        }
Пример #5
0
 public static List <GameModel> LoadGames(String search)
 {
     if (search == null)
     {
         string sql = @"select Id,Name,CreatedBy,Year,Console from dbo.Games;";
         return(SqlDataAccess.LoadData <GameModel>(sql));
     }
     else
     {
         string sql = @"select Id,Name,CreatedBy,Year,Console from dbo.Games " +
                      "where Name like '%" + search + "%' OR " +
                      "CreatedBy like '%" + search + "%' OR " +
                      "Year like '%" + search + "%' OR " +
                      "Console like '%" + search + "%'; ";
         return(SqlDataAccess.LoadData <GameModel>(sql));
     }
 }
Пример #6
0
        public static List <Car> LoadCars()
        {
            var        clientList = LoadClients();
            List <Car> totalList  = new List <Car>();

            foreach (var c in clientList)
            {
                var    tableName = ConvertToEnglish(c.Name) + "Cars";
                string sql       = @"SELECT ClientId, CarName, Model, VIN, EngineVolume, ManufactureYear, Defects
                            FROM dbo." + tableName;
                var    data      = SqlDataAccess.LoadData <Car>(sql);
                foreach (var row in data)
                {
                    totalList.Add(row);
                }
            }
            return(totalList);
        }
Пример #7
0
        public static int AuthenticateUser(string userName, string userPassword)
        {
            byte[]           passwordHash;
            byte[]           salt;
            string           find = "select * from dbo.Users where Username=@Username";
            List <UserModel> user;
            UserModel        data = new UserModel
            {
                Username = userName,
            };

            user = SqlDataAccess.LoadData(find, data);
            if (user.Count() != 0 & userPassword != null)
            {
                salt = user[0].Salt;
                using (var sha = new SHA512CryptoServiceProvider())
                {
                    var hashdata = Encoding.ASCII.GetBytes(userPassword).Concat(salt).ToArray <byte>();

                    var shadata = sha.ComputeHash(hashdata);
                    passwordHash = shadata;
                }
                if (passwordHash.SequenceEqual(user[0].Password))
                {
                    return(user[0].Id);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Пример #8
0
        public static List <BidModel> LoadBids()
        {
            string sql = @"select Id, Card, Date from dbo.Bid;";

            return(SqlDataAccess.LoadData <BidModel>(sql));
        }
Пример #9
0
        public static List <UserModel> LoadUserList()
        {
            string sql = "dbo.Load_UserList";

            return(SqlDataAccess.LoadData <UserModel>(sql));
        }
Пример #10
0
        public static List <GameModel> GetGamesOnSale(string id)
        {
            string sql = @"select Name,CreatedBy,Year,Console from dbo.Games where OwnerId ='" + id + "';";

            return(SqlDataAccess.LoadData <GameModel>(sql));
        }
Пример #11
0
        public static List <blogModel> LoadBlogs()
        {
            string sql = "select * from dbo.BlogData;";

            return(SqlDataAccess.LoadData <blogModel>(sql));
        }
        public static List <ComplaintModel> LoadComplaints()
        {
            string sql = "SELECT TenantId, PropertyManagerId, IncidentDate, Details, ComplaintStatusId, ComplaintTypeId, ReportedDate from dbo.Complaint;";

            return(SqlDataAccess.LoadData <ComplaintModel>(sql));
        }
Пример #13
0
        public static List <DBNoteModel> LoadNote()
        {
            string sql = @"select cim, tartalom from dbo.Note;";

            return(SqlDataAccess.LoadData <DBNoteModel>(sql));
        }
Пример #14
0
        public static List <AuctionModel> LoadAuctions()
        {
            string sql = @"select Id, Date, End_Date, Status, Description, Price from dbo.Auction;";

            return(SqlDataAccess.LoadData <AuctionModel>(sql));
        }
Пример #15
0
        public static List <ComplaintModel> LoadComplaint(int id)
        {
            string sql = "SELECT * FROM dbo.Complaint WHERE Id = '" + id + "';";

            return(SqlDataAccess.LoadData <ComplaintModel>(sql));
        }
Пример #16
0
        public static List <AccountModel> LoadAccounts()
        {
            string sql = "SELECT Id, FirstName, LastName, EmailAddress, Tenant, PropertyCode from dbo.Account;";

            return(SqlDataAccess.LoadData <AccountModel>(sql));
        }
Пример #17
0
        public static List <string> GetGamesSold(string id)
        {
            string sql = @"select gname from dbo.Purchases where sellerId = '" + id + "';";

            return(SqlDataAccess.LoadData <string>(sql));
        }