public async Task <ActionResult> DeleteConfirmed(int id) { ShippingRecord shippingRecord = await db.ShippingRecords.FindAsync(id); db.ShippingRecords.Remove(shippingRecord); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,ShippingCompanyId,ShippedDate,TrackingNumber")] ShippingRecord shippingRecord) { if (ModelState.IsValid) { db.Entry(shippingRecord).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ShippingCompanyId = new SelectList(db.ShippingCompanies, "Id", "Name", shippingRecord.ShippingCompanyId); return(View(shippingRecord)); }
// GET: ShippingRecords/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShippingRecord shippingRecord = await db.ShippingRecords.FindAsync(id); if (shippingRecord == null) { return(HttpNotFound()); } return(View(shippingRecord)); }
// GET: ShippingRecords/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShippingRecord shippingRecord = await db.ShippingRecords.FindAsync(id); if (shippingRecord == null) { return(HttpNotFound()); } ViewBag.ShippingCompanyId = new SelectList(db.ShippingCompanies, "Id", "Name", shippingRecord.ShippingCompanyId); return(View(shippingRecord)); }
private async Task AddTransaction(TransactionVM tr, int cartId, ShippingCompany shipCompany) { if (shipCompany == null) { shipCompany = db.ShippingCompanies.FirstOrDefault(s => s.Name == "Unknown"); } ShippingRecord sr = new ShippingRecord() { ShippingCompanyId = shipCompany.Id, TrackingNumber = tr.TrackingNumber }; db.ShippingRecords.Add(sr); await db.SaveChangesAsync(); TransactionRecord rec = tr.TransactionRecord; rec.ComputeFees(); rec.CartId = cartId; rec.ShippingRecordId = sr.Id; rec.ShippingRecord = sr; db.TransactionRecords.Add(rec); await db.SaveChangesAsync(); LogRecord shippingLog = new LogRecord() { DateTime = DateTime.Now, RecordType = Utilities.RecordType.New, Guid = typeof(ShippingRecord).GUID, RecordId = sr.Id }; db.LogRecords.Add(shippingLog); LogRecord transactionLog = new LogRecord() { DateTime = DateTime.Now, RecordType = Utilities.RecordType.New, Guid = typeof(TransactionRecord).GUID, RecordId = rec.Id }; db.LogRecords.Add(transactionLog); await db.SaveChangesAsync(); }