示例#1
0
        public JsonResult DeleteTransportation(string transportationName)
        {
            TransportationService ts = new TransportationService();

            ts.RemoveTransportation(transportationName);

            return(Json(ts.SelectAll()));
        }
示例#2
0
        public JsonResult AddTransportation(TransportationAddRequestModel model)
        {
            TransportationService ts = new TransportationService();

            switch (model.TransportType)
            {
            case "Boat":
                ITransportation newBoat = new Boat();
                newBoat.Name          = model.Name;
                newBoat.TransportMode = model.TransportMode;
                newBoat.PowerSource   = model.PowerSource;
                newBoat.Capacity      = model.Capacity;
                ts.AddTransportation(newBoat);
                break;

            case "Plane":
                ITransportation newPlane = new Plane();
                newPlane.Name          = model.Name;
                newPlane.TransportMode = model.TransportMode;
                newPlane.PowerSource   = model.PowerSource;
                newPlane.Capacity      = model.Capacity;
                ts.AddTransportation(newPlane);
                break;

            case "Auto":
                ITransportation newAuto = new Auto();
                newAuto.Name          = model.Name;
                newAuto.TransportMode = model.TransportMode;
                newAuto.PowerSource   = model.PowerSource;
                newAuto.Capacity      = model.Capacity;
                ts.AddTransportation(newAuto);
                break;

            case "Train":
                ITransportation newTrain = new Boat();
                newTrain.Name          = model.Name;
                newTrain.TransportMode = model.TransportMode;
                newTrain.PowerSource   = model.PowerSource;
                newTrain.Capacity      = model.Capacity;
                ts.AddTransportation(newTrain);
                break;
            }

            return(Json(ts.SelectAll()));
        }