Beispiel #1
0
        public Transaction Save(int propertyId, TransactionToSaveDto transactionDto)
        {
            var property = _propertyRepository.Get(propertyId);
            var account = _accountRepository.Get(transactionDto.AccountId);
            var category = _categoryRepository.Get(transactionDto.CategoryId);

            var transactionData = new Transaction(transactionDto.Value, transactionDto.Date.ToDate(), category, transactionDto.Description, account, property);

            var transaction = _transactionRepository.Get(transactionDto.Id);
            if (transaction.Id == 0)
                transaction = _transactionRepository.Add(transactionData);
            else
                _transactionRepository.Update(transactionData, transactionDto.Id);

            return transaction;
        }
Beispiel #2
0
        public ActionResult SaveTransaction(TransactionToSaveDto transaction)
        {
            var login = Request.Headers["login"];
            var token = Request.Headers["token"];
            var propertyId = Convert.ToInt32(Request.Headers["propertyId"]);

            if (!ValidatePost(login, token, propertyId))
                return Json("usuário inválido", JsonRequestBehavior.AllowGet);

            var transactionApp = new TransactionApp(_transactionRepository, _accountRepository, _categoryRepository, _propertyRepository);
            var transactionSaved = transactionApp.Save(propertyId, transaction);

            return Json(new { Status = "OK",  Message = string.Format("Lançamento de {0} em {1} salvo!", transactionSaved.Value, transactionSaved.Date.ToBrString()),  Item = transactionSaved });
        }
        public ActionResult Save(TransactionToSaveDto transaction, string novo)
        {
            _transactionApp.Save(SeletedPropertyId, transaction);

            return RedirectToAction(string.IsNullOrEmpty(novo) ? "Index" : "Save");
        }