public static void addChartorder(this tbl_chartsorder Chartorder, ChartOrderViewModel chartorderVM) { Chartorder.userid = chartorderVM.userid; Chartorder.user_name = chartorderVM.user_name; Chartorder.charts_order = "1,2,3,4,5,6"; }
public HttpResponseMessage SaveChartOrder(HttpRequestMessage request, ChartOrderViewModel chartorder) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { tbl_chartsorder newChartorder = new tbl_chartsorder(); newChartorder.addChartorder(chartorder); _chartorderRepository.Add(newChartorder); _unitOfWork.Commit(); response = request.CreateResponse <ChartOrderViewModel>(HttpStatusCode.Created, chartorder); } return response; })); }
public HttpResponseMessage UpdateChartOrderList(HttpRequestMessage request, ChartOrderViewModel chartorder) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var existingOrder = _chartorderRepository.GetAll().Where(x => x.userid == chartorder.userid).FirstOrDefault(); existingOrder.userid = chartorder.userid; existingOrder.user_name = chartorder.user_name; existingOrder.charts_order = chartorder.charts_order; _chartorderRepository.Edit(existingOrder); _unitOfWork.Commit(); response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }