public ActionResult DeleteConfirmed(long id) { AssetTransferLog assetTransferLog = db.AssetTransferLogs.Find(id); db.AssetTransferLogs.Remove(assetTransferLog); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,AssetID,TransferDate,FromAssetSN,ToAssetSN,FromDepartmentLocationID,ToDepartmentLocationID")] AssetTransferLog assetTransferLog) { if (ModelState.IsValid) { db.AssetTransferLogs.Add(assetTransferLog); db.SaveChanges(); return(Json("Successfully transfer Asset!")); } return(Json("Unable to transfer Asset!")); }
public ActionResult Create([Bind(Include = "ID,AssetID,TransferDate,FromAssetSN,ToAssetSN,FromDepartmentLocationID,ToDepartmentLocationID")] AssetTransferLog assetTransferLog) { if (ModelState.IsValid) { db.AssetTransferLogs.Add(assetTransferLog); db.SaveChanges(); return(Json("Completed Transfer!")); } return(Json("Unable to transfer Asset! Please check and try again!")); }
private async void btnSubmit_Clicked(object sender, EventArgs e) { if (pDepartment.SelectedItem == null || pLocation.SelectedItem == null) { await DisplayAlert("Transfer Assset", "Please ensure that the destinations are selected!", "Ok"); } else { var getNewDepartmentLocationID = (from x in _departmentLocationList join y in _departmentList on x.DepartmentID equals y.ID join z in _locationList on x.LocationID equals z.ID where y.Name == pDepartment.SelectedItem.ToString() && z.Name == pLocation.SelectedItem.ToString() select x.ID).FirstOrDefault(); var newTransfer = new AssetTransferLog() { AssetID = _asset.ID, FromAssetSN = _asset.AssetSN, ToAssetSN = lblAssetSN.Text, TransferDate = DateTime.Now, FromDepartmentLocationID = _asset.DepartmentLocationID, ToDepartmentLocationID = getNewDepartmentLocationID }; var client = new WebApi(); var jsonData = JsonConvert.SerializeObject(newTransfer); var response = await client.PostAsync(jsonData, "AssetTransferLogs/Create"); if (response == "\"Completed Transfer!\"") { await DisplayAlert("Transfer Asset", "Completed Transfer!", "Ok"); _asset.AssetSN = lblAssetSN.Text; _asset.DepartmentLocationID = getNewDepartmentLocationID; var jsonData2 = JsonConvert.SerializeObject(_asset); var responseAsset = await client.PostAsync(jsonData2, "Assets/Edit"); if (responseAsset == "\"Successfully edited Asset!\"") { await DisplayAlert("Edit Asset", "Successfully edited Asset!", "Ok"); await Navigation.PopAsync(); } else { await DisplayAlert("Edit Asset", "An error occured while editing Asset! Please contact our administrator!", "Ok"); } } else { await DisplayAlert("Transfer Asset", "Unable to transfer Asset! Please check and try again!", "Ok"); } } }
public ActionResult Edit([Bind(Include = "ID,AssetID,TransferDate,FromAssetSN,ToAssetSN,FromDepartmentLocationID,ToDepartmentLocationID")] AssetTransferLog assetTransferLog) { if (ModelState.IsValid) { db.Entry(assetTransferLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AssetID = new SelectList(db.Assets, "ID", "AssetSN", assetTransferLog.AssetID); ViewBag.FromDepartmentLocationID = new SelectList(db.DepartmentLocations, "ID", "ID", assetTransferLog.FromDepartmentLocationID); ViewBag.ToDepartmentLocationID = new SelectList(db.DepartmentLocations, "ID", "ID", assetTransferLog.ToDepartmentLocationID); return(View(assetTransferLog)); }
// GET: AssetTransferLogs/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AssetTransferLog assetTransferLog = db.AssetTransferLogs.Find(id); if (assetTransferLog == null) { return(HttpNotFound()); } return(View(assetTransferLog)); }
// GET: AssetTransferLogs/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AssetTransferLog assetTransferLog = db.AssetTransferLogs.Find(id); if (assetTransferLog == null) { return(HttpNotFound()); } ViewBag.AssetID = new SelectList(db.Assets, "ID", "AssetSN", assetTransferLog.AssetID); ViewBag.FromDepartmentLocationID = new SelectList(db.DepartmentLocations, "ID", "ID", assetTransferLog.FromDepartmentLocationID); ViewBag.ToDepartmentLocationID = new SelectList(db.DepartmentLocations, "ID", "ID", assetTransferLog.ToDepartmentLocationID); return(View(assetTransferLog)); }