Exemple #1
0
        public async Task Add(AddBillDto dto)
        {
            var amount   = _amountFactory.Create(dto.AmountValue, dto.Currency);
            var supplier = await GetSupplierByName(dto.Supplier, dto.UserId);

            var category = await GetCategoryByName(dto.Category, dto.UserId);

            var bill = _billFactory.Create(dto.Name, amount, dto.PaymentDate.Date, supplier, category, dto.UserId);

            await _billRepository.Add(bill);
        }
Exemple #2
0
        public async Task BillService_ShouldAddBill()
        {
            var bill = new AddBillDto
            {
                Name        = "rquestBill",
                AmountValue = 12,
                Category    = "Tet",
                Currency    = Currency.PLN,
                PaymentDate = DateTime.Now.AddDays(2),
                Supplier    = "Test2"
            };

            var content  = new StringContent(JsonConvert.SerializeObject(bill), Encoding.UTF8, "application/json");
            var response = await _client.PostAsync("api/bills", content);

            Assert.Contains("200", response.EnsureSuccessStatusCode().ToString());
        }
Exemple #3
0
 public async Task Post([FromBody] AddBillDto dto)
 {
     dto.UserId = User.Identity.Name;
     await _billService.Add(dto);
 }