public ActionResult Add(TransactionDTO dto) { var customerId = Helper.AddTransaction(dto); return RedirectToAction("Details", new RouteValueDictionary( new { controller = "Home", action = "Details", Id = customerId })); }
public static int AddTransaction(TransactionDTO dto) { int customerId; using (var db = new WebDBEntities()) { var transaction = new Transaction() { CreateDate = dto.CreateDate, CallDuration = dto.CallDuration, AccountId = dto.AccountId }; db.Transactions.Add(transaction); db.SaveChanges(); customerId = db.Accounts.First(r => r.Id == dto.AccountId).CustomerId; } return customerId; }
public static int UpdateTransfer(TransactionDTO dto) { using (var db = new WebDBEntities()) { var transaction = db.Transactions.FirstOrDefault(r => r.Id == dto.Id) ?? new Transaction { Id = dto.Id }; transaction.AccountId = dto.AccountId; transaction.CallDuration = dto.CallDuration; transaction.CreateDate = dto.CreateDate; db.Transactions.AddOrUpdate(transaction); db.SaveChanges(); return db.Accounts.First(r => r.Id == dto.AccountId).CustomerId; } }
public static TransactionDTO GetTransaction(int id) { using (var db = new WebDBEntities()) { var transaction = db.Transactions.First(r => r.Id == id); var dto = new TransactionDTO { Id = transaction.Id, CallDuration = transaction.CallDuration, CreateDate = transaction.CreateDate, AccountId = transaction.AccountId }; return dto; } }