public ActionResult TransactionAdd(Transaction model) { //var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); //var userId = UserManager.FindById(User.Identity.GetUserId()); using (ApplicationDbContext db = new ApplicationDbContext()) { model.UserId = System.Web.HttpContext.Current.User.Identity.GetUserId(); model.DateDeleted = null; db.Transactions.Add(model); db.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult TransactionEdit(Transaction model) { using (ApplicationDbContext db = new ApplicationDbContext()) { Transaction tempModel = db.Transactions.FirstOrDefault(x => x.TransactionId == model.TransactionId); tempModel.ModelId = model.ModelId; tempModel.DateSold = model.DateSold; tempModel.TransType = model.TransType; tempModel.SalePrice = model.SalePrice; tempModel.CarYear = model.CarYear; tempModel.NumsMatch = model.NumsMatch; tempModel.ExtColor = model.ExtColor; tempModel.IntColor = model.IntColor; tempModel.SellerName = model.SellerName; tempModel.BuyerName = model.BuyerName; tempModel.BuyerCountry = model.BuyerCountry; tempModel.Notes = model.Notes; db.SaveChanges(); } return View("TransactionDetails", model); }
public ActionResult TransactionAdd(int id) { Transaction model = new Transaction(); model.ModelId = id; return View("TransactionEdit", model); }