Я работаю с каркасом, где вы должны расширить новые модели, контроллеры.save new propertie asp.net mvc
Итак, есть вид. И теперь я пытаюсь добавить свойство этого существующего представления.
Новые СВОЙСТВ называются:
public virtual string Project_Number { get; set; }
и модель выглядит следующим образом:
public class OrderoverviewModel_ProjectNumber: OrderOverviewModel
{
[Display(Name = "ProjectNumber")]
[MaxLength(50, ErrorMessageResourceName = "Validation_MaxLength")]
public virtual string Project_Number { get; set; }
public OrderOverviewModel overViewModel { get; set; }
}
вид выглядит следующим образом:
@model Sana.Commerce.DomainModel.Order.OrderoverviewModel_ProjectNumber
<div class="additional-info">
<h4>@Sana.SimpleText("OrderOverview_AdditionalInformation")</h4>
@*@if (Shop.UserAbilities.Has(AbilityTo.AddReferenceNo))
{*@
<div class="form-row">
<div class="control">
<div class="label">
@Html.LabelFor(it => it.ReferenceNumber, htmlAttributes: new { @class = "lbl" })
</div>
<div class="field">
@Html.EditorFor(it => it.ReferenceNumber, new { tabindex = 1 })
</div>
</div>
<div class="validation">
@Html.ValidationMessageFor(it => it.ReferenceNumber)
</div>
</div>
@*}*@
@*@if (Shop.UserAbilities.Has(AbilityTo.AddReferenceNo))
{*@
<div class="form-row">
<div class="control">
<div class="label">
@Html.LabelFor(it => it.Project_Number, htmlAttributes: new { @class = "lbl" })
</div>
<div class="field">
@Html.EditorFor(it => it.Project_Number, new { tabindex = 1 })
</div>
</div>
<div class="validation">
@Html.ValidationMessageFor(it => it.Project_Number)
</div>
</div>
@*}*@
@if (Shop.UserAbilities.Has(AbilityTo.AddReferenceNo))
{
<div class="form-row">
<div class="control">
<div class="label">
@Html.LabelFor(it => it.Comments, htmlAttributes: new { @class = "lbl" })
</div>
<div class="field">
@Html.EditorFor(it => it.Comments, new { tabindex = 1 })
</div>
</div>
<div class="validation">
@Html.ValidationMessageFor(it => it.Comments)
</div>
</div>
}
@if (Shop.UserAbilities.Has(AbilityTo.AddRequestedDeliveryDate))
{
<div class="form-row">
<div class="control">
<div class="label">
@Html.LabelFor(it => it.DeliveryDate, htmlAttributes: new { @class = "lbl" })
</div>
<div class="field">
@Html.EditorFor(it => it.DeliveryDate, new { tabindex = 1 })
</div>
</div>
<div class="validation">
@Html.ValidationMessageFor(it => it.DeliveryDate)
</div>
</div>
}
</div>
Но у меня есть некоторые проблемы с Контроллер. Контроллер выглядит следующим образом:
public class ExtendedOrderManager : OrderManager<IExtendedOrderProvider>
{
public string CustomAction(int value)
{
var cacheKey = CacheKey.ForErpItem<object>("customaction_" + value, cacheGroup: "abc");
return CacheManager.FromCache(cacheKey,() => Provider.CustomAction(value));
}
public override IOrder SaveOrder(IOrder order)
{
//order.Fields.SetField(new Entities.EntityField("BlanketOrderId", "BO1") { StoreWithEntity = true });
//order["BlanketOrderId"] = "BO1";
//order.Fields["BlanketOrderId"].StoreWithEntity = true;
return base.SaveOrder(order);
}
}
IOrder выглядит следующим образом:
//
// Summary:
// This interface represents an order in the ERP system. This can be an order that
// still has to be placed or an order that is already in the ERP (for example order
// history). There are several types of orders like regular orders, invoice and
// quotes. The type of order is stored in the document type property.
public interface IOrder : IEntity, IVersionedItem
{
//
// Summary:
// ID of the account that placed the order.
string AccountId { get; set; }
//
// Summary:
// The type of account that placed this order.
AccountType AccountType { get; set; }
//
// Summary:
// Gets or sets the list of order attachments.
IList<IAttachment> Attachments { get; set; }
//
// Summary:
// Gets or sets the status of order authorization.
OrderAuthorizationStatus AuthorizationStatus { get; set; }
//
// Summary:
// Address that will recieve the invoice.
ICustomerAddress BillingAddress { get; set; }
//
// Summary:
// Gets or sets bill-to name.
string BillToName { get; set; }
//
// Summary:
// Gets or sets the comment.
string Comment { get; set; }
//
// Summary:
// Name of the Contact that placed this order.
string Contact { get; set; }
//
// Summary:
// ID of the Contact that placed this order.
string ContactId { get; set; }
//
// Summary:
// ID of the currency used to place this order (for example USD). This can be different
// from the current users default currency.
string CurrencyId { get; set; }
//
// Summary:
// The total amount of discount the customer gets over this order. This includes
// linediscount over all basketlines and invoice discount.
decimal DiscountAmount { get; set; }
//
// Summary:
// Document date.
Date? DocumentDate { get; set; }
//
// Summary:
// The OrderId (in the case of other types than Order or Quote).
string DocumentId { get; set; }
//
// Summary:
// Gets or sets the document type.
string DocumentType { get; set; }
//
// Summary:
// Due date.
Date? DueDate { get; set; }
//
// Summary:
// Gets or sets the value indicating whether this order has report.
bool HasReport { get; set; }
//
// Summary:
// The ID of the instance.
string Id { get; set; }
//
// Summary:
// The total amount of invoice discount the customer gets over his/her order. This
// is calculated using the totalprice without VAT.
decimal InvoiceDiscount { get; set; }
//
// Summary:
// Gets or sets a value indicating whether this quote is confirmed.
bool IsQuoteConfirmed { get; set; }
//
// Summary:
// Location code.
string LocationCode { get; set; }
//
// Summary:
// Gets or sets the max expired date.
DateTime? MaxExpirationDate { get; set; }
//
// Summary:
// Date on which the order was placed.
Date OrderDate { get; set; }
//
// Summary:
// The order lines.
IList<IOrderLine> OrderLines { get; set; }
//
// Summary:
// The number of order lines.
int OrderLinesCount { get; set; }
//
// Summary:
// Gets or sets the order type.
OrderType? OrderType { get; set; }
//
// Summary:
// The ID of the sales order which this document is linked to. For example, if it
// is an 'Invoice' document then this field should be the ID of the sales order
// for which this invoice has been posted. In case this is an 'Order' or 'Quote'
// document type then this field should be empty.
string OriginalOrderId { get; set; }
//
// Summary:
// Gets or sets the original quote identifier.
string OriginalQuoteId { get; set; }
//
// Summary:
// The total amount outstanding.
decimal OutstandingAmount { get; set; }
//
// Summary:
// Address of the company the order was paid by.
ICustomerAddress PayerAddress { get; set; }
//
// Summary:
// Payment Discount.
decimal PaymentDiscount { get; set; }
//
// Summary:
// Payment Discount Date.
Date? PaymentDiscountDate { get; set; }
//
// Summary:
// Name of the payment method used by the customer.
string PaymentMethod { get; set; }
//
// Summary:
// Status of the Payment of this order.
string PaymentStatus { get; set; }
//
// Summary:
// Payment terms code.
string PaymentTermsCode { get; set; }
//
// Summary:
// The payment transaction ID.
string PaymentTransactionId { get; set; }
//
// Summary:
// Posting Date.
Date? PostingDate { get; set; }
//
// Summary:
// Gets or sets the prepayment amount.
decimal PrepaymentAmount { get; set; }
//
// Summary:
// Gets or sets the prepayment percentage.
decimal PrepaymentPercentage { get; set; }
//
// Summary:
// Gets or sets a value indicating whether prices include tax.
bool PricesInclTax { get; set; }
//
// Summary:
// Promised Delivery Date.
Date? PromisedDeliveryDate { get; set; }
//
// Summary:
// Gets or sets the reference no.
string ReferenceNo { get; set; }
//
// Summary:
// Requested Delivery Date.
Date? RequestedDeliveryDate { get; set; }
//
// Summary:
// The round-off value, which is added or substracted from the subtotal value when
// the rounding precision of total costs is corrected on the ERP side.
decimal RoundOff { get; set; }
//
// Summary:
// Name of the sales person that placed this order.
string SalesPerson { get; set; }
//
// Summary:
// ID of the sales person that placed this order.
string SalesPersonId { get; set; }
//
// Summary:
// Gets or sets the Sana internal order identifier.
string SanaOrderId { get; set; }
//
// Summary:
// Address of the company the order was selled to.
ICustomerAddress SellToAddress { get; set; }
//
// Summary:
// Date the order was shipped.
Date? ShipmentDate { get; set; }
//
// Summary:
// Address this order will or was shipped to.
ICustomerAddress ShippingAddress { get; set; }
//
// Summary:
// Code (string) of the method the order was shipped by.
string ShippingMethodCode { get; set; }
//
// Summary:
// Name of the method the order was shipped by.
string ShippingMethodName { get; set; }
//
// Summary:
// Gets or sets the shipping status. Order is shipped only if order lines are shipped.
string ShippingStatus { get; set; }
//
// Summary:
// The shipping tracking link provided by the shipping agent.
string ShippingTrackingLink { get; set; }
//
// Summary:
// The shipping tracking number provided by the shipping agent.
string ShippingTrackingNumber { get; set; }
//
// Summary:
// Gets or sets ship-to name.
string ShipToName { get; set; }
//
// Summary:
// Gets or sets the e-mail address of the shop account who placed this order.
string ShopAccountEmail { get; set; }
//
// Summary:
// Gets or sets the status of this order.
OrderStatus Status { get; set; }
//
// Summary:
// The total Amount of tax the user has to pay over all basket lines.
decimal TaxAmount { get; set; }
//
// Summary:
// The lines containing taxes.
IList<ITaxLine> TaxLines { get; set; }
//
// Summary:
// The percentage of tax that is used for this order (for example when tax is 19%,
// this property contains 19).
decimal TaxPercent { get; set; }
//
// Summary:
// The total price of all products of this order including invoice discount and
// VAT.
decimal TotalPrice { get; set; }
//
// Summary:
// The total price of all products of this order without any discounts or tax added.
decimal TotalPriceExcludingDiscount { get; set; }
//
// Summary:
// The total price of all products of this order including invoice discount, but
// excluding tax.
decimal TotalPriceExcludingTax { get; set; }
//
// Summary:
// The Total number of products this order contains.
decimal TotalQuantity { get; }
//
// Summary:
// The ID of the website.
string WebsiteId { get; set; }
}
Но это DLL. Поэтому я не могу добавить новые свойства в класс IOrder.
Потому что, если я ставлю точку останова на методе контроллера: SaveOrder
и я наблюдаю свойства в порядке IOrder порядке. Я вижу, что projectnumber имеет значение null.
Так что мой вопрос: как управлять тем, что номер проекта получает значение?
Спасибо
И это класс заказ:
[Serializable]
[DataContract(Namespace = "")]
public class Order : Entity, IOrder
{
#region Properties
/// <summary>
/// Status of the Payment of this order.
/// </summary>
[DataMember]
public string PaymentStatus { get; set; }
[DataMember]
[XmlField]
public string ProjectNumber { get; set; }
/// <summary>
/// The address the customer should recieve the bill.
}
Так я добавил новый Inteface так:
interface IOrderProjectNumber:IOrder
{
string ProjectNumber { get; set; }
}
Если посмотреть в методе: SaveOrder (Iorder order), и я наводил указатель мыши на то, что я вижу, что свойство ProjectNumber имеет значение
Но если я посмотрю в ближайшее окно, и если я сделаю это:? Order.proje ... Я не вижу проект projectnumber? Как это может быть?
Спасибо enter image description here
Пожалуйста, разместите только соответствующий код. Другие могут запутаться. А также четко объясните свою проблему. – ViVi
Сначала в SaveOrder создайте одну переменную и произведите заказ на OrderoverviewModel_ProjectNumber. Проверьте, получаете ли вы значение. Кроме того, при сохранении после base.save вам нужно добавить дополнительную логику, чтобы сохранить номер проекта. То же самое происходит при извлечении. – Amit