public static CateringOrder ToModel(this BackendCateringViewModelItem viewmodel) { CateringOrder model = new CateringOrder(); model.ID = viewmodel.ID; model.OrderState = viewmodel.Status.Key; return(model); }
public static BackendCateringViewModelItem FromModel(this BackendCateringViewModelItem viewmodel, CateringOrder model) { viewmodel.ID = model.ID; viewmodel.Event.FromModel(model.Event); viewmodel.User.FromModel(model.User); viewmodel.SeatNumber = model.Seat.SeatNumber; viewmodel.Order = model.CateringOrderDetail.ToList().ConvertAll(x => { return(new BackendCateringOrderItem().FromModel(x)); }); viewmodel.Status = new BackendCateringStatusOption(model.OrderState); viewmodel.Note = model.Note; viewmodel.Registered = model.Registered; return(viewmodel); }
public IHttpActionResult Backend_Detail_Update(Int32 id, BackendCateringViewModelItem request) { BackendCateringViewModel viewmodel = new BackendCateringViewModel(); CateringOrderDataController dataCtrl = new CateringOrderDataController(); try { dataCtrl.Update(request.ToModel()); } catch (Exception ex) { return(Error(viewmodel, ex)); } return(Ok(viewmodel, "Eintrag wurde gespeichert.")); }