Exemplo n.º 1
0
 public void UpdateTire(tire thetire)
 {
     try
     {
         tire theNewTire = db.tire.Single(x => x.tireID == thetire.tireID);
         db.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 2
0
 public void CreateTire(tire theTires)
 {
     try
     {
         tire theTire = theTires;
         db.tire.Add(theTire);
         db.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 3
0
        public void InfoSubmit(tire t)
        {
            bool isAdd = tireService.Update(t);

            if (isAdd)
            {
                //return Content("<script >alert('提交成功!');history.go(-1);</script >", "text/html");
            }
            else
            {
                //return Content("<script >alert('提交失败!');history.go(-1);</script >", "text/html");
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var cars = new List <Car>();

            for (int counter = 0; counter < n; counter++)
            {
                var    tokens      = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string model       = tokens[0];
                int    engineSpeed = int.Parse(tokens[1]);
                int    enginePower = int.Parse(tokens[2]);
                int    cargoWeight = int.Parse(tokens[3]);
                string cargoType   = tokens[4];

                double Tire1Pressure = double.Parse(tokens[5]);
                int    Tire1Age      = int.Parse(tokens[6]);
                double Tire2Pressure = double.Parse(tokens[7]);
                int    Tire2Age      = int.Parse(tokens[8]);
                double Tire3Pressure = double.Parse(tokens[9]);
                int    Tire3Age      = int.Parse(tokens[10]);
                double Tire4Pressure = double.Parse(tokens[11]);
                int    Tire4Age      = int.Parse(tokens[12]);


                var    engine = new engine(engineSpeed, enginePower);
                var    cargo  = new cargo(cargoWeight, cargoType);
                tire[] tires  = new tire[4];
                tires[0] = new tire(Tire1Pressure, Tire1Age);
                tires[1] = new tire(Tire2Pressure, Tire2Age);
                tires[2] = new tire(Tire3Pressure, Tire3Age);
                tires[3] = new tire(Tire4Pressure, Tire4Age);

                Car car = new Car(model, engine, cargo, tires);
                cars.Add(car);
            }

            string command = Console.ReadLine();

            if (command == "fragile")
            {
                cars.Where(c => c.Cargo.Type == "fragile" && c.Tires.Any(t => t.Pressure < 1)).ToList().ForEach(c => Console.WriteLine(c.Model));
            }
            else
            {
                cars.Where(p => p.Engine.Power > 250).ToList().ForEach(c => Console.WriteLine(c.Model));
            }
        }
Exemplo n.º 5
0
        public JsonResult Download(string value)
        {
            List <tire> list = tireService.GetModels(p => (p.TireID == value)).ToList();

            if (list.Count == 0)
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
            else
            {
                tire   t  = list[0];
                String dt = t.CreateTime.ToString();

                return(Json(t, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
0
        public ActionResult EditTire(FormCollection form)
        {
            var tireID    = form["tireID"];
            var brand     = form["brand"].ToUpperInvariant();
            var dimension = form["dimension"].ToUpperInvariant();
            var type      = form["type"].ToUpperInvariant();
            var season    = form["season"].ToUpperInvariant();
            var tbc       = form["tbc"].ToUpperInvariant();
            var rl        = form["rl"].ToUpperInvariant();
            var bd        = form["bd"].ToUpperInvariant();
            var sd        = form["sd"];
            var inprice   = form["inprice"];
            var outpriceA = form["outpriceA"];
            var outpriceB = form["outpriceB"];
            var balance   = form["balance"];


            tire theTire = dbc.GetATire(Convert.ToInt32(tireID));

            theTire.brand               = brand;
            theTire.dimension           = dimension;
            theTire.type                = type;
            theTire.season              = season;
            theTire.tirebearingcapacity = tbc;
            theTire.rollingresistance   = rl;
            theTire.breakingdistance    = bd;
            theTire.sounddecibel        = sd;
            theTire.inprice             = Convert.ToDecimal(inprice);
            theTire.outpriceA           = Convert.ToDecimal(outpriceA);
            theTire.outpriceB           = Convert.ToDecimal(outpriceB);
            theTire.balance             = Convert.ToInt32(balance);

            dbc.UpdateTire(theTire);


            TempData["UpdateTire"] = "Du har uppdaterat däcket!";
            HttpCookie Newcookie = Request.Cookies["User"];

            Newcookie.Expires = DateTime.Now.AddHours(5);
            user theuser = new user();

            theuser          = dbc.GetUser(Convert.ToInt32(Newcookie.Value));
            TempData["user"] = theuser.userID;
            return(View(theTire));
        }
Exemplo n.º 7
0
        public ActionResult EditTire(int id)
        {
            HttpCookie Newcookie = Request.Cookies["User"];

            if (Newcookie.Value == "1" || Newcookie.Value == "4")
            {
                Newcookie.Expires = DateTime.Now.AddHours(5);
                user theuser = new user();
                theuser          = dbc.GetUser(Convert.ToInt32(Newcookie.Value));
                TempData["user"] = theuser.userID;

                tire theTire = dbc.GetATire(id);
                return(View(theTire));
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
Exemplo n.º 8
0
        public tire GetATire(int id)
        {
            tire theTire = db.tire.Find(id);

            return(theTire);
        }