Exemplo n.º 1
0
        public Dirtbike MapDirtbike(DirtbikeModel iDirtbikeModel)
        {
            // Create constructor
            Dirtbike iDirtbike = new Dirtbike(iDirtbikeModel.DirtBikeID, iDirtbikeModel.Make, iDirtbikeModel.MakeYear, iDirtbikeModel.Model);

            return(iDirtbike);
        }
Exemplo n.º 2
0
        public List <Dirtbike> Select(Dirtbike iDirtbike)
        {
            List <Dirtbike> listDirtbike = new List <Dirtbike>();
            DirtbikeDAL     iDirtbikeDAL = new DirtbikeDAL();

            listDirtbike = iDirtbikeDAL.SelectDirtbike(iDirtbike);
            return(listDirtbike);
        }
Exemplo n.º 3
0
        // User view for all parts
        public ActionResult ViewAllParts(DirtbikeModel iDirtbikeModel, PartModel iPartModel)
        {
            // Must be logged in to any role to access this view
            if (((LoginModel)Session["loginModel"]) != null)
            {
                MapperDirtbike map       = new MapperDirtbike();
                Dirtbike       iDirtbike = new Dirtbike();
                iDirtbike = map.MapDirtbike(iDirtbikeModel);
                DirtbikeBLL selectDirtbike = new DirtbikeBLL();

                // Returned list of Dirtbikes from Database
                List <Dirtbike> listDirtbike = selectDirtbike.Select(iDirtbike);

                /* Get Dirtbike values from database and set it to
                 * viewbag to pass it to view for drop downlist*/
                IEnumerable <SelectListItem> makes = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.Make,
                    Text  = m.Make
                });
                ViewBag.Make = makes;
                IEnumerable <SelectListItem> makeYear = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.MakeYear.ToString(),
                    Text  = m.MakeYear.ToString()
                });
                ViewBag.MakeYear = makeYear;
                IEnumerable <SelectListItem> models = listDirtbike.Select(m => new SelectListItem
                {
                    Value = m.Model,
                    Text  = m.Model
                });
                ViewBag.Model = models;


                /* PartModel */
                PartMapper partMap = new PartMapper();
                Part       iPart   = new Part();
                iPart = partMap.MapDirtbike(iPartModel);
                PartBLL selectPart = new PartBLL();

                // Create List object for returned parts
                List <Part> listParts = selectPart.SelectAllParts(iPart);

                return(View(listParts));
            }
            else
            {
                return(RedirectToAction("login", "home"));
            }
        }
Exemplo n.º 4
0
        public List <Dirtbike> SelectDirtbike(Dirtbike iDirtbike)
        {
            List <Dirtbike> dirtbikeList = new List <Dirtbike>();

            ExceptionHandling e = new ExceptionHandling();

            string dbConnection = System.Configuration.ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString;

            try
            {
                using (SqlConnection conn = new SqlConnection(dbConnection))
                {
                    using (SqlCommand command = new SqlCommand("SP_SELECT_DIRTBIKE", conn))
                    {
                        command.CommandType    = System.Data.CommandType.StoredProcedure;
                        command.CommandTimeout = 30;
                        conn.Open();

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Dirtbike db = new Dirtbike();
                                db.DirtBikeID = (int)reader["DirtBikeID"];
                                db.Make       = reader["Make"].ToString();
                                db.MakeYear   = (int)reader["MakeYear"];
                                db.Model      = reader["Model"].ToString();

                                dirtbikeList.Add(db);
                            }
                        }
                        command.ExecuteNonQuery();
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                e.WriteLogger(ex);
                e.InsertLoggerToDB(ex);
            }
            return(dirtbikeList);
        }