public IActionResult AddOrEdit(WaybillViewModel emp) { if (emp.Vehicle_Number_Plate == null) { HttpResponseMessage response = Globalvariables.client.PostAsJsonAsync("api/Waybills", emp).Result; TempData["SuccessMessage"] = "Saved Successfully"; return(RedirectToAction("Index")); } else { Waybillddl lc = new Waybillddl(); int Vehicle_Registration_Number = (from x in lc.GetVehicleId() where x.Vehicle_Number_Plate == emp.Vehicle_Number_Plate select x.Vehicle_Registration_Number).Single(); WaybillViewModel obj = new WaybillViewModel(); obj.WaybillId = emp.WaybillId; obj.Waybill_Total_weight = emp.Waybill_Total_weight; obj.Waybil_Total_Parcels_Allocated = emp.Waybil_Total_Parcels_Allocated; obj.Vehicle_Registration_Number = Vehicle_Registration_Number; obj.Vehicle_Number_Plate = emp.Vehicle_Number_Plate; HttpResponseMessage response = Globalvariables.client.PostAsJsonAsync("api/Waybills", obj).Result; TempData["SuccessMessage"] = "Saved Successfully"; return(RedirectToAction("Index")); } }
public ActionResult AddorEdit(WaybillViewModel way) { if (way.wayBillID == 0) { HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("TritonExpressWaybills", way).Result; TempData["SuccessW"] = "Save Successfully"; } else { HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("TritonExpressWaybills/" + way.wayBillID, way).Result; TempData["SuccessW"] = "Updated Successfully"; } return(RedirectToAction("Index")); }