コード例 #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ShippingRecord shippingRecord = await db.ShippingRecords.FindAsync(id);

            db.ShippingRecords.Remove(shippingRecord);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        // 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));
        }
コード例 #4
0
        // 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));
        }
コード例 #5
0
        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();
        }