当前位置: 首页>>代码示例>>C#>>正文


C# EntityRef.GetVanillaEntity方法代码示例

本文整理汇总了C#中EntityRef.GetVanillaEntity方法的典型用法代码示例。如果您正苦于以下问题:C# EntityRef.GetVanillaEntity方法的具体用法?C# EntityRef.GetVanillaEntity怎么用?C# EntityRef.GetVanillaEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityRef的用法示例。


在下文中一共展示了EntityRef.GetVanillaEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReportLostBook

        public void ReportLostBook( EntityRef<Rental> rentalRef )
        {
            if ( rentalRef.IsNull )
                throw new ArgumentNullException( "rentalRef" );

            Rental rental = rentalRef.GetVanillaEntity();
            Book book = rental.Book.GetVanillaEntity();

            // Check business rules.
            BusinessRulesManager.Assert( "ReportLostBook", rental );

            // Apply the penalty.
            CustomerAccountLine penalty = new CustomerAccountLine
                                              {
                                                  Customer = rental.Customer,
                                                  Employee = this.Session.Employee,
                                                  Rental = rentalRef,
                                                  Date = DateTime.Today,
                                                  Amount = -book.LostPenalty,
                                                  Description = string.Format(
                                                      "Lost of the book [{0}; {1}]",
                                                      book.Authors,
                                                      book.Title )
                                              };
            this.customerProcesses.AddCustomerAccountLine( penalty );

            // Create a note for the penalty.
            Note note = new Note
                            {
                                Owner = rental,
                                Employee = this.Session.Employee,
                                Date = DateTime.Now,
                                Title = "Penalty Applied",
                                Text = string.Format(
                                    "A penalty of {2} EUR was applied for the lost of the book [{0}; {1}]",
                                    book.Authors,
                                    book.Title,
                                    -penalty.Amount )
                            };
            StorageContext.Current.Insert( note );

            // Update the rental.
            rental.ReturnDate = DateTime.Now;
            rental.Closed = true;
            StorageContext.Current.Update( rental );

            // Delete the book.
            book.Deleted = true;
            StorageContext.Current.Update( book );
        }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:50,代码来源:RentalProcesses.cs

示例2: DeleteCustomer

      //  [Transaction]
        public void DeleteCustomer( EntityRef<Customer> customerRef )
        {
            if ( customerRef.IsNull )
                throw new ArgumentNullException( "customerRef" );

            // Get a safe version of the customer.
            Customer customer = customerRef.GetVanillaEntity();

            // Check business rules.
            BusinessRulesManager.Assert( "DeleteCustomer", customer );

            // Update the 'Deleted' flag.
            customer.Deleted = true;
            StorageContext.Current.Update( customer );
        }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:16,代码来源:CustomerProcesses.cs

示例3: ReturnBook

        public void ReturnBook( EntityRef<Rental> rentalRef )
        {
            if ( rentalRef.IsNull )
                throw new ArgumentNullException( "rentalRef" );

            Rental rental = rentalRef.GetVanillaEntity();

            // Check business rules.
            BusinessRulesManager.Assert( "ReturnBook", rental );

            // Check if the book has been returned in time and apply penalty.
            if ( DateTime.Today > rental.ScheduledReturnDate )
            {
                int delay = (int) Math.Ceiling( ( DateTime.Today - rental.ScheduledReturnDate ).TotalDays );

                CustomerAccountLine penalty = new CustomerAccountLine
                                                  {
                                                      Customer = rental.Customer,
                                                      Employee = this.Session.Employee,
                                                      Rental = rentalRef,
                                                      Date = DateTime.Today,
                                                      Amount = -0.1M*delay,
                                                      Description = string.Format(
                                                          "Delay of {0} day(s) while returning the book [{1}; {2}]",
                                                          delay,
                                                          rental.Book.Entity.Authors,
                                                          rental.Book.Entity.Title )
                                                  };

                this.customerProcesses.AddCustomerAccountLine( penalty );


                Note note = new Note
                                {
                                    Owner = rental,
                                    Title = "Penalty Applied",
                                    Employee = this.Session.Employee,
                                    Date = DateTime.Now,
                                    Text = string.Format(
                                        "A penalty of {3} EUR was applied for a {0}-day(s) delay while returning the book [{1}; {2}]",
                                        delay,
                                        rental.Book.Entity.Authors,
                                        rental.Book.Entity.Title,
                                        -penalty.Amount )
                                };
                StorageContext.Current.Insert( note );
            }

            rental.ReturnDate = DateTime.Now;
            rental.Closed = true;
            StorageContext.Current.Update( rental );
        }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:52,代码来源:RentalProcesses.cs

示例4: GetCustomerInfo

        public CustomerInfo GetCustomerInfo( EntityRef<Customer> customer, bool getAllRentals )
        {
            if ( customer.IsNull )
                throw new ArgumentNullException( "customer" );

            CustomerInfo customerInfo = new CustomerInfo {Customer = customer.GetVanillaEntity(), Rentals = new List<RentalInfo>()};

            foreach ( Rental rental in StorageContext.Current.Find<Rental>( candidate => candidate.Customer == customer && (getAllRentals || !candidate.Closed) ) )
            {
                RentalInfo rentalInfo = new RentalInfo();
                rentalInfo.Book = rental.Book.Entity;
                rentalInfo.Rental = rental;
                rentalInfo.Notes = new List<Note>( StorageContext.Current.Find<Note>( candidate => candidate.Owner == rental ) );
                customerInfo.Rentals.Add( rentalInfo );
            }

            customerInfo.AccountLines = new List<CustomerAccountLine>( StorageContext.Current.Find<CustomerAccountLine>(
                                                                           candidate => candidate.Customer == customer ) );

            return customerInfo;
        }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:21,代码来源:CustomerProcesses.cs


注:本文中的EntityRef.GetVanillaEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。