0

我正在尝试使用 postman web api 对我的记录进行修补,但不知何故 salesOrderStatusId 没有得到更新,该属性是枚举类型。

修补:

{
    "SalesOrderNumber": "S0001",
    "salesOrderStatusId": 2,
    "ApptType": false
},

财产:

public Nullable<SalesOrderStatus> SalesOrderStatusId { get; set; }

行动:

[ActionName("DefaultAction")]
public override HttpResponseMessage Patch(int SalesOrderId, Delta<SalesOrder> NewSalesOrder)
{
    var SalesOrder = _uow.Repository<SalesOrder>().Find(SalesOrderId);

    if (SalesOrder == null)
        return Request.CreateResponse(HttpStatusCode.NotFound);

    NewSalesOrder.Patch(SalesOrder);

    SalesOrder.ObjectState = ObjectState.Modified;

    _uow.Repository<SalesOrder>().Update(SalesOrder);

    try
    {
        _uow.Save();

        return Request.CreateResponse(HttpStatusCode.Created, SalesOrder);
    }
    catch (DbUpdateConcurrencyException)
    {
        return Request.CreateResponse(HttpStatusCode.BadRequest);
    }
}
4

0 回答 0