コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TransportationId,DeliveryDate,StartDate,TruckFid")] Transportation transportation)
        {
            if (id != transportation.TransportationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transportation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransportationExists(transportation.TransportationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TruckFid"] = new SelectList(_context.Trucks, "TruckId", "TruckId", transportation.TruckFid);
            return(View(transportation));
        }
コード例 #2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTypeTransportation.Text != "")
                {
                    Transportation transportation = new Transportation(Convert.ToDouble(txtPriceTransport.Text),
                                                                       dtTransportationTime.Text, txtTypeTransportation.Text);
                    transportationController.AddTransportation(transportation);
                }

                if (txtHoteName.Text != "")
                {
                    Hotel hotel = new Hotel(Convert.ToDouble(txtPriceHotel.Text),
                                            dtTransportationTime.Text, txtHoteName.Text, txtAddressHotel.Text);
                    hotelController.AddHotel(hotel);
                }

                if (txtTitleEntertainment.Text != "")
                {
                    Entertainment entertainment = new Entertainment(Convert.ToDouble(txtEnterPrice.Text), dtEventEntertainment.Text,
                                                                    txtTitleEntertainment.Text, txtDescriptionEntertainment.Text);
                    entertainmentController.AddEvent(entertainment);
                }

                lblMessage.Text = "Success";
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
コード例 #3
0
    public void SerializeObject(string filename)
    {
        // Create an XmlSerializer instance.
        XmlSerializer xSer = CreateOverrider();

        // Create the object.
        Transportation myTransportation =
            new Transportation();

        /* Create two new, overriding objects that can be
         * inserted into the Vehicles array. */
        myTransportation.Vehicles = new ArrayList();
        Truck myTruck = new Truck();

        myTruck.Name = "MyTruck";

        Train myTrain = new Train();

        myTrain.Name = "MyTrain";

        myTransportation.Vehicles.Add(myTruck);
        myTransportation.Vehicles.Add(myTrain);

        TextWriter writer = new StreamWriter(filename);

        xSer.Serialize(writer, myTransportation);
    }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userId         = message.GetBody <Guid>();
            var transportation = new Transportation
            {
                TransportationId = Guid.NewGuid(),
                IsActive         = true,
                CreatedAt        = DateTime.UtcNow.Subtract(DateTime.MinValue.AddYears(1969)).TotalSeconds
            };
            await _transportationRepository.SaveTransportation(transportation, userId);

            WriteLog($"Handling queue message {message.MessageId}");

            var payload = new PostTransporationResultMessage
            {
                TransportationId = transportation.TransportationId
            };
            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Post-Transportation-Queue");
        }
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Id != null)
                {
                    hashCode = hashCode * 59 + Id.GetHashCode();
                }
                if (Transportation != null)
                {
                    hashCode = hashCode * 59 + Transportation.GetHashCode();
                }

                hashCode = hashCode * 59 + TravelTime.GetHashCode();
                if (DepartureTime != null)
                {
                    hashCode = hashCode * 59 + DepartureTime.GetHashCode();
                }
                if (Properties != null)
                {
                    hashCode = hashCode * 59 + Properties.GetHashCode();
                }
                if (Range != null)
                {
                    hashCode = hashCode * 59 + Range.GetHashCode();
                }
                return(hashCode);
            }
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("id,material_weight,carriage_weight,material_unit_price,carriage_unit_price,material_count_price,carriage_count_price,start_date,end_date,customer,shareholder,car,supply,material,carriage_should_count_price,service_charge,pay_time")] Transportation transportation)
        {
            if (ModelState.IsValid)
            {
                Customer customer = _context.customer.Where(p => p.id == transportation.customer.id).First();

                transportation.customer = customer;

                Material material = _context.material.Where(p => p.id == transportation.material.id).First();

                transportation.material = material;

                Car car = _context.car.Where(p => p.id == transportation.car.id).First();

                transportation.car = car;

                Supply supply = _context.supply.Where(p => p.id == transportation.supply.id).First();

                transportation.supply = supply;

                transportation.create_time = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                _context.Add(transportation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(transportation));
        }
コード例 #7
0
    public void SerializeObject(string filename)
    {
        // Create an XmlSerializer instance.
        XmlSerializer xSer = CreateOverrider();

        // Create object and serialize it.
        Transportation myTransportation =
            new Transportation();

        Car c1 = new Car();

        c1.ID = 12;

        Car c2 = new Car();

        c2.ID = 44;

        myTransportation.Cars = new Car[2] {
            c1, c2
        };

        // To write the file, a TextWriter is required.
        TextWriter writer = new StreamWriter(filename);

        xSer.Serialize(writer, myTransportation);
    }
コード例 #8
0
 public HttpResponseMessage UpdateTransportation(Transportation transportation)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
         TransportationDictionary = (Dictionary <string, Transportation>)HttpContext.Current.Application["Dictionary"];
         if (TransportationDictionary == null)
         {
             TransportationDictionary = new Dictionary <string, Transportation>();
             return(Request.CreateResponse(HttpStatusCode.OK, "There is nothing to update here."));
         }
         else
         {
             TransportationDictionary = (Dictionary <string, Transportation>)HttpContext.Current.Application["Dictionary"];
             TransportationDictionary[transportation.Name] = transportation;
             HttpContext.Current.Application["Dictionary"] = TransportationDictionary;
             return(Request.CreateResponse(HttpStatusCode.OK, ReturnStr));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
コード例 #9
0
        public async Task <IActionResult> Edit_Receive(int id, [Bind("id,material_weight,carriage_weight,material_unit_price,carriage_unit_price,material_count_price,carriage_count_price,start_date,end_date,customer,shareholder,car,supply,material,carriage_should_count_price,service_charge,pay_time")] Transportation transportation)
        {
            if (id != transportation.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Transportation _trasportation = _context.transportation.Where(p => p.id == id).First();

                    _trasportation.end_date                    = transportation.end_date;
                    _trasportation.carriage_weight             = transportation.carriage_weight;
                    _trasportation.carriage_should_count_price = transportation.carriage_should_count_price;

                    _context.Update(_trasportation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransportationExists(transportation.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(transportation));
        }
コード例 #10
0
        public void calculateProductUnitPrice(Product product, ProductDetailCalculatorParameter parameter)
        {
            ProductDetail productDetail = null;

            if (product.ProductType != null)
            {
                if (product.ProductType.Equals("FoodAndBeverageItems"))
                {
                    productDetail = new FoodAndBeverage(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("MaterialItems"))
                {
                    productDetail = new Material(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("GarmentItems"))
                {
                    productDetail = new Garment(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("TransportationServices"))
                {
                    productDetail = new Transportation(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("TelecommunicationServices"))
                {
                    productDetail = new Telecommunication(this.Delimeter, product);
                }
                else
                {
                    throw new Exception("Unknown Product Type");
                }

                productDetail.setAdditionalParameter(parameter);
                product.UnitPrice = productDetail.calculateProductCost() * productDetail.getDecCostRate();
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: balee323/TeachingCode
        static void Main(string[] args)
        {
            Transportation fuckinThingThatMoves = new Transportation();

            Console.WriteLine("this thing is moving speed" + fuckinThingThatMoves.Speed);


            Motorcycle fingMotorBike = new Motorcycle();

            Console.WriteLine("this thing is moving speed" + fingMotorBike.Speed);
            Console.WriteLine("this thing has an engine size" + fingMotorBike.MotorSize);

            //modular, I switch out parts
            IMotorVehicle myVehicle = new Car();  //interface  //like anything else, an interface is a tool

            Console.WriteLine("this thing is moving speed" + myVehicle.GetSpeed());
            Console.WriteLine("this thing has an engine size" + myVehicle.MotorSize);

            // you use tools where they make sense...

            //Motorcycle motorcycle = new Motorcycle();
            //int Milage = motorcycle.GetMilage();

            //motorcycle.Color = "Green";



            //IMotorVehicle motorvehicle = new Car();

            //motorvehicle.Color = "Green";
        }
コード例 #12
0
    private void SerializeObject(string filename)
    {
        // Creates an XmlSerializer for the Transportation class.
        XmlSerializer MySerializer =
            new XmlSerializer(typeof(Transportation));

        // Writing the XML file to disk requires a TextWriter.
        TextWriter myTextWriter = new StreamWriter(filename);

        Transportation myTransportation = new Transportation();

        Vehicle myVehicle = new Vehicle();

        myVehicle.id = "A12345";

        Car myCar = new Car();

        myCar.id    = "Car 34";
        myCar.Maker = "FamousCarMaker";

        Vehicle [] myVehicles = { myVehicle, myCar };
        myTransportation.MyVehicles = myVehicles;

        // Serializes the object, and closes the StreamWriter.
        MySerializer.Serialize(myTextWriter, myTransportation);
        myTextWriter.Close();
    }
コード例 #13
0
        public void instantiationProduct(Product product, ProductDetailCalculatorParameter parameter)
        {
            ProductDetail productDetail = null;

            if (product.ProductType != null)
            {
                if (product.ProductType.Equals("FoodAndBeverageItems"))
                {
                    productDetail = new FoodAndBeverage(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("MaterialItems"))
                {
                    productDetail = new Material(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("GarmentItems"))
                {
                    productDetail = new Garment(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("TransportationServices"))
                {
                    productDetail = new Transportation(this.Delimeter, product);
                }
                else if (product.ProductType.Equals("TelecommunicationServices"))
                {
                    productDetail = new Telecommunication(this.Delimeter, product);
                }
                else
                {
                    throw new Exception("Unknown Product Type");
                }
            }
        }
コード例 #14
0
 public ShoppingTripEntryModel(int shoppingTripId, string creator, string name, DateTime startTime, Transportation transportation)
 {
     ShoppingTripId = shoppingTripId;
     Creator        = creator;
     Name           = name;
     StartTime      = startTime;
     Transportation = transportation;
 }
コード例 #15
0
        public ActionResult DeleteConfirmed(string id)
        {
            Transportation transportation = db.transportations.Find(id);

            db.transportations.Remove(transportation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #16
0
 public async Task PatchTransportationStatus(Transportation transportation)
 {
     var query = new CypherFluentQuery(_graphClientFunc)
                 .MatchEntity(transportation, "transportation")
                 .Set("transportation.isActive = {isActive}")
                 .WithParam("isActive", transportation.IsActive);
     await query.ExecuteWithoutResultsAsync();
 }
コード例 #17
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Transportation transportation = await db.Transportation.FindAsync(id);

            db.Transportation.Remove(transportation);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #18
0
 public ShoppingTripModel(string creator, string name, string reason, DateTime startTime, Transportation transportation, LocationDto location, List <ShoppingTripItemModel> shoppingTripItems)
 {
     Creator           = creator;
     Name              = name;
     Reason            = reason;
     StartTime         = startTime;
     Transportation    = transportation;
     Location          = location;
     ShoppingTripItems = shoppingTripItems;
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: Saroj404/visual-studio
        static void InheritenceExample()
        {
            Transportation t   = new Transportation();
            Transportation lt  = new LandTransport();
            LandTransport  lt2 = new LandTransport();

            t.FunctionOne();
            lt.FunctionOne();
            lt2.FunctionOne();
        }
コード例 #20
0
 public ActionResult Edit([Bind(Include = "ID,CityFrom,CityTo")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(transportation));
 }
コード例 #21
0
 public ActionResult Edit([Bind(Include = "TransportationId,TransportationName,CraeteDate,Show")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(transportation));
 }
        /// <summary>
        /// Returns true if RequestTimeFilterDepartureSearch instances are equal
        /// </summary>
        /// <param name="other">Instance of RequestTimeFilterDepartureSearch to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RequestTimeFilterDepartureSearch other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     DepartureLocationId == other.DepartureLocationId ||
                     DepartureLocationId != null &&
                     DepartureLocationId.Equals(other.DepartureLocationId)
                 ) &&
                 (
                     ArrivalLocationIds == other.ArrivalLocationIds ||
                     ArrivalLocationIds != null &&
                     other.ArrivalLocationIds != null &&
                     ArrivalLocationIds.SequenceEqual(other.ArrivalLocationIds)
                 ) &&
                 (
                     Transportation == other.Transportation ||
                     Transportation != null &&
                     Transportation.Equals(other.Transportation)
                 ) &&
                 (
                     TravelTime == other.TravelTime ||

                     TravelTime.Equals(other.TravelTime)
                 ) &&
                 (
                     DepartureTime == other.DepartureTime ||
                     DepartureTime != null &&
                     DepartureTime.Equals(other.DepartureTime)
                 ) &&
                 (
                     Properties == other.Properties ||
                     Properties != null &&
                     other.Properties != null &&
                     Properties.SequenceEqual(other.Properties)
                 ) &&
                 (
                     Range == other.Range ||
                     Range != null &&
                     Range.Equals(other.Range)
                 ));
        }
コード例 #23
0
        public ActionResult Create([Bind(Include = "ID,CityFrom,CityTo")] Transportation transportation)
        {
            if (ModelState.IsValid)
            {
                db.Transportations.Add(transportation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(transportation));
        }
コード例 #24
0
 public ExchangeAndRemoval(IExchangeAndRemoval removal)
 {
     IsEnabled = removal.IsEnabled;
     Transportation = new Transportation(removal.Transportation);
     TravelRestrict = new TravelRestrict(removal.TravelRestrict);
     IsChildAbductionRiskExist = removal.IsChildAbductionRiskExist;
     IsDV145Attached = removal.IsDV145Attached;
     IsUSCountryOfHabitualResidence = removal.IsUSCountryOfHabitualResidence;
     IsOtherCountryOfHabitualResidence = removal.IsOtherCountryOfHabitualResidence;
     OtherCountryAsHabitualResidenceDescription = removal.OtherCountryAsHabitualResidenceDescription;
 }
コード例 #25
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,Amount,BudgetId,DayId")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Days", new { id = transportation.DayId }));
     }
     ViewBag.BudgetId = new SelectList(db.Budgets, "Id", "Id", transportation.BudgetId);
     return(View(transportation));
 }
コード例 #26
0
 public ActionResult Edit([Bind(Include = "TransportationID,TransportationMode,CustomerID")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", transportation.CustomerID);
     return(View(transportation));
 }
コード例 #27
0
        public ActionResult Create([Bind(Include = "TransportationId,TransportationName,CraeteDate,Show")] Transportation transportation)
        {
            if (ModelState.IsValid)
            {
                db.transportations.Add(transportation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(transportation));
        }
コード例 #28
0
 public ActionResult Edit([Bind(Include = "Transportation_Id,Transportation_Name,Transportation_Details,Transportation_Img,TouristSpot_Id,Transportation_Create")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TouristSpot_Id = new SelectList(db.TouristSpots, "TouristSpot_Id", "TouristSpot_Name", transportation.TouristSpot_Id);
     return(View(transportation));
 }
コード例 #29
0
 public ActionResult Edit([Bind(Include = "Id,DateTimeDeparture,PlanId")] Transportation transportation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transportation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlanId = new SelectList(db.Plans, "Id", "Id", transportation.PlanId);
     return(View(transportation));
 }
コード例 #30
0
        public void GetExportType()
        {
            ContainerConfiguration config = new ContainerConfiguration();

            config.WithAssembly(Assembly.GetExecutingAssembly());
            using (CompositionHost host = config.CreateContainer())
            {
                Transportation c = host.GetExport <Car>();
                Transportation b = host.GetExport <Bike>();
                Console.WriteLine($"c.Identity : {c.Identity}\nb.Indentity : {b.Identity}");
            }
        }
コード例 #31
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,BudgetId,Amount,DayId")] Transportation transportation)
        {
            if (ModelState.IsValid)
            {
                db.Transportations.Add(transportation);
                db.SaveChanges();
                return(RedirectToAction("CreateExpenseVM", "Days", new { id = transportation.DayId })); // Edited by TRH changed params
            }

            ViewBag.BudgetId = new SelectList(db.Budgets, "Id", "Id", transportation.BudgetId);
            return(View(transportation));
        }
コード例 #32
0
 public TransportationViewModel(Transportation transportationInfo, NotificationApplicationCompletionProgress progress)
 {
     NotificationId = transportationInfo.NotificationId;
     NotificationType = transportationInfo.NotificationType;
     IsCarrierCompleted = progress.HasCarrier;
     IsMeansOfTransportCompleted = progress.HasMeansOfTransport;
     IsPackagingTypesCompleted = progress.HasPackagingInfo;
     IsSpecialHandlingCompleted = progress.HasSpecialHandlingRequirements;
     Carriers = transportationInfo.Carriers;
     MeanOfTransport = transportationInfo.MeanOfTransport;
     PackagingData = transportationInfo.PackagingData;
     SpecialHandlingDetails = transportationInfo.SpecialHandlingDetails;
 }
コード例 #33
0
ファイル: Trade.cs プロジェクト: Garfield-Chen/mabicommerce
        public Trade(Transportation transport, Route route, Load load, TradingPost source, TradingPost destination, List<Modifier> modifiers)
        {
            Destination = destination;
            Load = load;
            Route = route;
            Transport = transport;
            Modifiers = modifiers;

            BaseDuration = TimeSpan.FromSeconds(route.Duration.TotalSeconds / Transport.SpeedFactor);
            BaseCost = load.Slots.Sum(i => i.Key.Price * i.Value);
            BaseProfit = BaseGold = BaseMerchantRating = load.CalculateProfit(destination);
            BaseExperience = load.CalculateExperience(destination);

            Cost = BaseCost;
            Profit = (int)(BaseProfit * (1 + modifiers.Sum(m => m.ProfitBonus)));
            Gold = (int)(BaseGold * (1 + modifiers.Sum(m => m.GoldBonus)));
            MerchantRating = (int)(BaseMerchantRating * (1 + modifiers.Sum(m => m.MerchantRatingBonus)));
            Experience = (int)(BaseExperience * (1 + modifiers.Sum(m => m.ExpBonus)));
            Duration =
                TimeSpan.FromSeconds(route.Duration.TotalSeconds / (Transport.SpeedFactor + modifiers.Sum(m => m.SpeedBonus)));

            Gold = Math.Max(0, Gold);
            MerchantRating = Math.Max(0, MerchantRating);
            Experience = Math.Max(0, Experience);

            AddedCost = Cost - BaseCost;
            AddedProfit = Profit - BaseProfit;
            AddedGold = Gold - BaseGold;
            AddedMerchantRating = MerchantRating - BaseMerchantRating;
            AddedExperience = Experience - BaseExperience;
            AddedDuration = Duration - BaseDuration;

            ProfitPerSecond = Profit / Duration.TotalSeconds;

            if (source.NoProfits.Contains(destination.Id))
                Flags |= TradeFlags.NoProfit;

            if (route.Path.Select(w => w.Target.Region).Any(r => r.ChokePoint))
                Flags |= TradeFlags.ChokePoint;

            ModifierNames = string.Join(", ", Modifiers.Select(m => m.Name));
        }
コード例 #34
0
 public ExchangeAndRemoval()
 {
     Transportation = new Transportation();
     TravelRestrict = new TravelRestrict();
 }
コード例 #35
0
ファイル: Cell.cs プロジェクト: Maxbey/transport-problem
 public void RemoveTransportation()
 {
     _transportation = null;
 }
コード例 #36
0
ファイル: Cell.cs プロジェクト: Maxbey/transport-problem
 public void AddTransportation(Transportation transportation)
 {
     _transportation = transportation;
 }