public ActionResult <string> PatchOrder([FromBody] OrderPatchModel OrderPatchModel) { System.Console.WriteLine("hellow??asdfasdfasfdasf"); Customer customerOut; bool sdfs = _authenticator.InnerValidate(OrderPatchModel.token, out customerOut); if (sdfs == true) { System.Console.WriteLine("token: " + customerOut.CustomerToken); System.Console.WriteLine("log orderModel:"); System.Console.WriteLine(OrderPatchModel); if (_orderLogic.UpdateStackCountfromOrder(customerOut, OrderPatchModel)) { return(JsonConvert.SerializeObject(customerOut, new Newtonsoft.Json.JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore })); } else { return(StatusCode(401)); } } return(StatusCode(401)); }
public static OrderPatchModel ToPatchModal(this Order order) { var result = new OrderPatchModel { Name = order.Name }; return(result); }
/// <summary> /// delete the stack in the model from the order of the customer /// </summary> /// <param name="customerOut"></param> /// <param name="odModel"></param> public bool UpdateStackCountfromOrder(Customer customer, OrderPatchModel odModel) { bool success = false; if (odModel.newUpdatedStackCount != null) { foreach (var stackInt in odModel.newUpdatedStackCount) { if (!_toyRepository.ChangeSellablStackCountInCustomerOrder(customer, stackInt.Key, stackInt.Value)) { return(false); } else { success = true; } } } return(success); }