public dynamic SaveMobileDemandOrder([FromBody] Newtonsoft.Json.Linq.JObject param) { dynamic objParamInfo = param; dynamic objresponse = null; string DemandOrderID = objParamInfo.DemandOrderID != null ? objParamInfo.DemandOrderID : "0"; string CustomerID = objParamInfo.CustomerID; DateTime deliveryorderDate = objParamInfo.deliveryorderDate; DateTime deliveryDate = objParamInfo.deliveryDate; int driverID = objParamInfo.driverID; int bowserID = objParamInfo.bowserID; string remark = objParamInfo.remark; DateTime Date = DateTime.Now; try { string customerId = _session.GetString("LoginUserID"); if (CustomerID == customerId) { var sobj = _repositoryWrapper.DemandOrder.FindByString(DemandOrderID); if (sobj != null) { sobj.demandorderID = objParamInfo.DemandOrderID; sobj.deliveryorderDate = objParamInfo.deliveryorderDate; sobj.deliveryDate = objParamInfo.deliveryDate; sobj.driverID = objParamInfo.driverID; sobj.bowserID = objParamInfo.bowserID; sobj.customerID = objParamInfo.CustomerID; sobj.createuser = Convert.ToInt32(CustomerID); sobj.userType = true; sobj.remark = objParamInfo.remark; sobj.modifieddate = System.DateTime.Now; sobj.inactive = true; _repositoryWrapper.DemandOrder.Update(sobj); for (int i = 0; i < objParamInfo.data.Count; i++) { string DemandOrderDetailID = objParamInfo.data[i].DemandOrderDetailID; var dobj = _repositoryWrapper.DemandOrderDetail.FindByString(DemandOrderDetailID); dobj.orderdetailID = DemandOrderDetailID; dobj.demandorderID = DemandOrderID; dobj.productID = objParamInfo.data[i].id; dobj.compartmentID = objParamInfo.data[i].CompartmentID; dobj.orderliter = objParamInfo.data[i].OrderLiter; dobj.modifieddate = System.DateTime.Now; dobj.inactive = true; _repositoryWrapper.DemandOrderDetail.Update(dobj); } } else { DemandOrderID = _repositoryWrapper.DemandOrder.GetDemandOrderNo(); var newobj = new DemandOrder(); newobj.demandorderID = DemandOrderID; newobj.customerID = Convert.ToInt32(CustomerID); newobj.deliveryorderDate = deliveryorderDate; newobj.deliveryDate = deliveryDate; newobj.driverID = driverID; newobj.bowserID = bowserID; newobj.status = 2; sobj.createuser = Convert.ToInt32(CustomerID); sobj.userType = true; newobj.modifieddate = Date; newobj.inactive = true; newobj.remark = remark; _repositoryWrapper.DemandOrder.Create(newobj); for (int i = 0; i < objParamInfo.data.Count; i++) { string DemandOrderDetailID = _repositoryWrapper.DemandOrderDetail.GetDemandOrderDetailNo(); var dobj = new DemandOrderDetail(); dobj.orderdetailID = DemandOrderDetailID; dobj.demandorderID = DemandOrderID; dobj.productID = objParamInfo.data[i].id; dobj.compartmentID = objParamInfo.data[i].CompartmentID; dobj.orderliter = objParamInfo.data[i].OrderLiter; dobj.modifieddate = System.DateTime.Now; dobj.inactive = true; _repositoryWrapper.DemandOrderDetail.Create(dobj); } } objresponse = new { status = 1, message = "Success" }; } else { String Message = "Sorry! Please Try Again "; objresponse = new { status = 0, message = Message }; } } catch (ValidationException vex) { objresponse = new { status = 0, message = "Sorry! Please Try Again" }; Console.WriteLine(vex.Message); } return(objresponse); }
public dynamic SaveDemandOrder([FromBody] Newtonsoft.Json.Linq.JObject param) { dynamic obj = param; dynamic objresponse = null; int LoginID = Int32.Parse(_tokenData.UserID); string DemandOrderID = obj.DemandOrderID != null ? obj.DemandOrderID : "0"; string CompanyID = _tokenData.CompanyID; try { var sobj = _repositoryWrapper.DemandOrder.FindByString(DemandOrderID); if (sobj != null) { sobj.deliveryorderDate = obj.DeliveryOrderDate; sobj.deliveryDate = obj.DeliveryDate; sobj.customerID = obj.customerID; sobj.bowserID = obj.bowserID; sobj.driverID = obj.driverID; sobj.status = obj.status; sobj.createuser = LoginID; sobj.userType = false; sobj.modifieddate = System.DateTime.Now; sobj.inactive = true; _repositoryWrapper.DemandOrder.Update(sobj); _repositoryWrapper.EventLog.Update(sobj); for (int i = 0; i < obj.data.Count; i++) { string DemandOrderDetailID = obj.data[i].DemandOrderDetailID != null ? obj.data[i].DemandOrderDetailID : "0"; //var deleteDetail =_repositoryWrapper.DemandOrde var dobj = _repositoryWrapper.DemandOrderDetail.FindByString(DemandOrderDetailID); if (dobj != null) { dobj.orderdetailID = DemandOrderDetailID; dobj.demandorderID = DemandOrderID; dobj.productID = obj.data[i].id; dobj.compartmentID = obj.data[i].CompartmentId; dobj.orderliter = obj.data[i].OrderLiter; dobj.modifieddate = System.DateTime.Now; dobj.inactive = true; _repositoryWrapper.DemandOrderDetail.Update(dobj); _repositoryWrapper.EventLog.Update(dobj); } else { DemandOrderDetailID = _repositoryWrapper.DemandOrderDetail.GetDemandOrderDetailNo(); var ddobj = new DemandOrderDetail(); ddobj.orderdetailID = DemandOrderDetailID; ddobj.demandorderID = DemandOrderID; ddobj.productID = obj.data[i].id; ddobj.compartmentID = obj.data[i].CompartmentId; ddobj.orderliter = obj.data[i].OrderLiter; ddobj.modifieddate = System.DateTime.Now; ddobj.inactive = true; _repositoryWrapper.DemandOrderDetail.Create(ddobj); _repositoryWrapper.EventLog.Insert(ddobj); } } } else { DemandOrderID = _repositoryWrapper.DemandOrder.GetDemandOrderNo(); var newobj = new DemandOrder(); newobj.demandorderID = DemandOrderID; newobj.customerID = obj.customerID; newobj.bowserID = obj.bowserID; newobj.driverID = obj.driverID; newobj.deliveryDate = obj.DeliveryDate; newobj.deliveryorderDate = obj.DeliveryOrderDate; newobj.status = 1; newobj.createuser = LoginID; newobj.userType = false; newobj.modifieddate = System.DateTime.Now; newobj.inactive = true; _repositoryWrapper.DemandOrder.Create(newobj); _repositoryWrapper.EventLog.Insert(newobj); for (int i = 0; i < obj.data.Count; i++) { string DemandOrderDetailID = _repositoryWrapper.DemandOrderDetail.GetDemandOrderDetailNo(); var dobj = new DemandOrderDetail(); dobj.orderdetailID = DemandOrderDetailID; dobj.demandorderID = DemandOrderID; dobj.productID = obj.data[i].id; dobj.compartmentID = obj.data[i].CompartmentId; dobj.orderliter = obj.data[i].OrderLiter; dobj.modifieddate = System.DateTime.Now; dobj.inactive = true; _repositoryWrapper.DemandOrderDetail.Create(dobj); _repositoryWrapper.EventLog.Insert(dobj); } } objresponse = new { data = DemandOrderID }; } catch (ValidationException vex) { _repositoryWrapper.EventLog.Error("DemandOrder Controller/ Save DemandOrder", vex.Message); objresponse = new { data = 0, error = vex.ValidationResult.ErrorMessage }; Console.WriteLine(vex.Message); } return(objresponse); }