Beispiel #1
0
        public XHRResponse <_Receipt> Create(string userId, _ReceiptCreate data)
        {
            XHRResponse <_Receipt> result = new XHRResponse <_Receipt>();

            try
            {
                Receipt receipt = Mapper.Map <Receipt>(data);
                receipt.AccountId    = userId;
                receipt.CreatedDate  = DateTime.Now;
                receipt.ModifiedDate = DateTime.Now;

                _receiptRepository.Insert(receipt);
                _receiptRepository.Save();

                _receiptRepository.Load(receipt, nameof(Category));
                _receiptRepository.Load(receipt, nameof(Payment));

                result.Data      = Mapper.Map <_Receipt>(receipt);
                result.Succeeded = true;
            }
            catch (Exception ex)
            {
                result.Message   = "Unable to create receipt.";
                result.Succeeded = false;
            }

            return(result);
        }
 public IActionResult Post(_ReceiptCreate data)
 {
     return(Ok(_receiptService.Create(UserId, data)));
 }