public IActionResult Get(int id) { try { var model = facade.ReadById(id); var viewModel = mapper.Map <GarmentBeacukaiViewModel>(model); if (viewModel == null) { throw new Exception("Invalid Id"); } foreach (var item in viewModel.items) { GarmentDeliveryOrder deliveryOrder = DOfacade.ReadById((int)item.deliveryOrder.Id); if (deliveryOrder != null) { GarmentDeliveryOrderViewModel deliveryOrderViewModel = mapper.Map <GarmentDeliveryOrderViewModel>(deliveryOrder); item.deliveryOrder.isInvoice = deliveryOrderViewModel.isInvoice; item.deliveryOrder.items = deliveryOrderViewModel.items; } } Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(viewModel); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public IActionResult Get(int id) { try { var model = facade.ReadById(id); var viewModel = mapper.Map <GarmentBeacukaiViewModel>(model); if (viewModel == null) { throw new Exception("Invalid Id"); } Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.OK_STATUS_CODE, General.OK_MESSAGE) .Ok(viewModel); return(Ok(Result)); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }