public IHttpActionResult GetLaptopListByStatus(ITEStatus Param)
        {
            JSON          JSONReturn = new JSON();
            List <Laptop> laptops    = new List <Laptop>();

            laptops = ITInventoryDBAccess.GetLaptopListByStatus(Param);

            JSONReturn.Data    = laptops;
            JSONReturn.Message = "Success";

            return(Json(JSONReturn));
        }
Пример #2
0
        public List <Laptop> GetLaptopListByStatus(ITEStatus status)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["LLFCWebFormsDB"].ConnectionString;

            List <Laptop> laptops = new List <Laptop>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("GetLaptopListByStatus", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@StatusID", status.StatusID);

                conn.Open();

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var Laptop       = new Laptop();
                    var ITEInventory = new ITEInventory();

                    Laptop.ITEInventory = ITEInventory;

                    Laptop.ITEInventory.ITEInventoryID = Convert.ToInt32(reader["ITE_Inventory_ID"]);
                    Laptop.ITEInventory.CategoryID     = Convert.ToInt32(reader["Category_ID_FK"]);
                    Laptop.ITEInventory.StatusID       = Convert.ToInt32(reader["Status_ID_FK"]);
                    Laptop.ITEInventory.DateAcquired   = Convert.ToDateTime(reader["Date_Acquired"]);
                    Laptop.ITEInventory.Price          = Convert.ToDecimal(reader["Price"]);

                    Laptop.LaptopID         = Convert.ToInt32(reader["Laptop_ID"]);
                    Laptop.SerialNumber     = reader["Laptop_Serial_Number"].ToString();
                    Laptop.LaptopBrand      = reader["Laptop_Brand"].ToString();
                    Laptop.LaptopModel      = reader["Laptop_Model"].ToString();
                    Laptop.Description      = Laptop.LaptopBrand + " " + Laptop.LaptopModel;
                    Laptop.LaptopStorage    = reader["Laptop_Storage"].ToString();
                    Laptop.LaptopScreenSize = reader["Laptop_Screen_Size"].ToString();
                    Laptop.LaptopProcessor  = reader["Laptop_Processor"].ToString();
                    Laptop.LaptopRAM        = reader["Laptop_RAM"].ToString();
                    Laptop.LaptopOS         = reader["Laptop_OS"].ToString();

                    laptops.Add(Laptop);
                }
            }

            return(laptops);
        }