Example #1
0
        public ActionResult Add(TransactionDTO dto)
        {
            var customerId = Helper.AddTransaction(dto);

            return RedirectToAction("Details", new RouteValueDictionary(
                new { controller = "Home", action = "Details", Id = customerId }));
        }
Example #2
0
        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;
        }
Example #3
0
        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;
            }
        }
Example #4
0
        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;
            }
        }