无法更新Enum类型的记录字段

时间:2014-02-25 03:57:53

标签: c# asp.net-web-api postman

我正在尝试使用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);
    }
}

0 个答案:

没有答案