コード例 #1
0
        public ActionResult Add(TransactionDTO dto)
        {
            var customerId = Helper.AddTransaction(dto);

            return RedirectToAction("Details", new RouteValueDictionary(
                new { controller = "Home", action = "Details", Id = customerId }));
        }
コード例 #2
0
ファイル: Helper.cs プロジェクト: crowar/MVCDemo
        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;
        }
コード例 #3
0
ファイル: Helper.cs プロジェクト: crowar/MVCDemo
        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;
            }
        }
コード例 #4
0
ファイル: Helper.cs プロジェクト: crowar/MVCDemo
        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;
            }
        }