예제 #1
0
        public IHttpActionResult Update(Rp3.Test.Common.Models.Transaction transaction)
        {
            //Complete the code
            using (DataService service = new DataService())
            {
                Rp3.Test.Data.Models.Transaction model = service.Transactions.GetByID(transaction.TransactionId);


                service.Transactions.Update(model);
                service.SaveChanges();
            }

            return(Ok());
        }
예제 #2
0
        public IHttpActionResult Insert(Rp3.Test.Common.Models.Transaction transaction)
        {
            //Complete the code
            using (DataService service = new DataService())
            {
                Rp3.Test.Data.Models.Transaction model = new Test.Data.Models.Transaction();
                model.TransactionId = service.Transactions.GetMaxValue <int>(p => p.TransactionId, 0) + 1;



                service.Transactions.Insert(model);
                service.SaveChanges();
            }

            return(Ok());
        }
예제 #3
0
        public IHttpActionResult Update(Rp3.Test.Common.Models.Transaction transaction)
        {
            //Complete the code
            using (DataService service = new DataService())
            {
                Rp3.Test.Data.Models.Transaction model = service.Transactions.GetByID(transaction.TransactionId);
                model.TransactionId     = transaction.TransactionId;
                model.TransactionTypeId = transaction.TransactionTypeId;
                model.RegisterDate      = transaction.RegisterDate;
                model.Notes             = transaction.Notes;
                model.ShortDescription  = transaction.ShortDescription;
                model.PersonId          = transaction.PersonId;
                model.CategoryId        = transaction.CategoryId;
                model.Amount            = transaction.Amount;

                service.Transactions.Update(model);
                service.SaveChanges();
            }

            return(Ok());
        }
예제 #4
0
        public IHttpActionResult Update(Rp3.Test.Common.Models.Transaction transaction)
        {
            using (DataService service = new DataService())
            {
                Rp3.Test.Data.Models.Transaction transactionModel = new Test.Data.Models.Transaction();
                transactionModel.RegisterDate      = transaction.RegisterDate;
                transactionModel.Amount            = transaction.Amount;
                transactionModel.Notes             = transaction.Notes;
                transactionModel.TransactionTypeId = transaction.TransactionTypeId;
                transactionModel.CategoryId        = transaction.CategoryId;
                transactionModel.TransactionId     = transaction.TransactionId;
                transactionModel.ShortDescription  = transaction.ShortDescription;
                transactionModel.DateUpdate        = transaction.DateUpdate;
                transactionModel.UserId            = transaction.UserId;

                service.Transactions.Update(transactionModel);
                service.SaveChanges();
            }

            return(Ok(true));
        }
예제 #5
0
        /// <summary>
        /// Inserta un regsitro de transacción
        /// </summary>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public IHttpActionResult Insert(Rp3.Test.Common.Models.Transaction transaction)
        {
            //Complete the code
            using (DataService service = new DataService())
            {
                Rp3.Test.Data.Models.Transaction model = new Test.Data.Models.Transaction();
                model.TransactionId     = service.Transactions.GetMaxValue <int>(p => p.TransactionId, 0) + 1;
                model.TransactionTypeId = transaction.TransactionTypeId;
                model.CategoryId        = transaction.CategoryId;
                model.RegisterDate      = transaction.RegisterDate;
                model.ShortDescription  = transaction.ShortDescription;
                model.Amount            = transaction.Amount;
                model.Notes             = transaction.Notes;
                model.PersonId          = transaction.PersonId;

                service.Transactions.Insert(model);
                service.SaveChanges();
            }

            return(Ok());
        }
예제 #6
0
        public IHttpActionResult GetById(int transactionId)
        {
            Rp3.Test.Common.Models.Transaction commonModel = null;
            using (DataService service = new DataService())
            {
                var model = service.Transactions.GetByID(transactionId);

                commonModel = new Common.Models.Transaction()
                {
                    TransactionId     = model.TransactionId,
                    TransactionTypeId = model.TransactionTypeId,
                    CategoryId        = model.CategoryId,
                    RegisterDate      = model.RegisterDate,
                    ShortDescription  = model.ShortDescription,
                    Amount            = model.Amount,
                    Notes             = model.Notes,
                    UserId            = model.UserId,
                    DateUpdate        = model.DateUpdate
                };
            }
            return(Ok(commonModel));
        }