Esempio n. 1
0
        public virtual ViewResult Preview(long id)
        {
            var bill = _bills.Get(id);

            BillModel model;

            if (bill == null)
            {
                model = _modelFactory.GetBillModelByApplication(id);
                var application = _applications.Get(id);
                ViewBag.BillNumber = application.DisplayNumber;
                ViewBag.SaveDate   = DateTimeProvider.Now;
                ViewBag.SendDate   = null;
            }
            else
            {
                model = _modelFactory.GetBillModel(bill);
                ViewBag.BillNumber = bill.Number;
                ViewBag.SaveDate   = bill.SaveDate;
                ViewBag.SendDate   = bill.SendDate;
            }

            ViewBag.ApplicationId = id;

            return(View(model));
        }
Esempio n. 2
0
        public async Task Update(UpdateBillDto dto)
        {
            var bill = await _billRepository.Get(dto.BillId);

            var amount   = _amountFactory.Create(dto.AmountValue, dto.Currency);
            var supplier = await GetSupplier(dto.SupplierId);

            var category = await GetCategory(dto.CategoryId);

            bill.Update(dto.Name, amount, dto.PaymentDate, dto.PaymentStatus, supplier, category);

            await _billRepository.Update(bill);
        }
Esempio n. 3
0
        public HttpResponseMessage Get(int id)
        {
            var bills = _billRepository.Get(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, bills);

            return(response);
        }
Esempio n. 4
0
        public void Test_AddBill()
        {
            var model  = _fixture.Create <BillModel>();
            var number = _fixture.Create <int>();

            _manager.Save(TestConstants.TestApplicationId, number, model, DateTimeProvider.Now, null);

            var billData = _billRepository.Get(TestConstants.TestApplicationId);

            billData.Number.ShouldBeEquivalentTo(number);
            billData.SendDate.Should().NotHaveValue();
            Debug.Assert(model.PriceRuble != null, "model.PriceRuble != null");
            billData.Price.Should().BeApproximately(model.PriceRuble.Value / billData.EuroToRuble, (decimal)0.0001);
            billData.ShouldBeEquivalentTo(model, options => options.ExcludingMissingProperties());
            billData.ShouldBeEquivalentTo(model.BankDetails, options => options.ExcludingMissingProperties());
        }
Esempio n. 5
0
        public IHttpActionResult Get([FromUri] string id)
        {
            var eBill = _billRepo.Get(b => b.Id == id && b.AgingStatus == Core.Common.AgingStatus.Regular);

            if (eBill == null)
            {
                return(NotFound());
            }
            var dtoBill = ModelFactory.Create(eBill);

            return(Ok(dtoBill));
        }
Esempio n. 6
0
        public FileHolder Get(long applicationId)
        {
            var bill = _bills.Get(applicationId);

            using (var stream = new MemoryStream())
                using (var document = new Document(PageSize.A4, 30, 30, 30, 30))
                {
                    PdfWriter.GetInstance(document, stream);
                    document.Open();
                    Fill(document, bill);
                    document.Close();

                    return(new FileHolder
                    {
                        Name = "bill-" + bill.Number + ".pdf",
                        Data = stream.ToArray()
                    });
                }
        }
Esempio n. 7
0
        public void Send(long applicationId, long userId)
        {
            var bill        = _bills.Get(applicationId);
            var application = _applications.Get(applicationId);

            var subject = string.Format("Счет на оплату № {0} от {1}", bill.Number, bill.SaveDate.ToString("dd MMMM yyyy"));
            var body    = subject;
            var from    = EmailsHelper.DefaultFrom;
            var to      = _admins.GetAll().Select(x => x.Email).ToArray()
                          .Union(EmailsHelper.SplitAndTrimEmails(application.ClientEmails))
                          .Distinct()
                          .ToArray();
            var files = new[] { _pdf.Get(applicationId) };

            foreach (var item in to)
            {
                _mail.Send(new EmailMessage(subject, body, from, item, userId)
                {
                    Files = files,
                });
            }
        }
 public VBillWithOrganization Get(int Id)
 {
     return(_repository.Get(Id).ToServiceLayer());
 }
Esempio n. 9
0
 public Bill GetBill(int id)
 {
     return(Repository.Get(id));
 }
Esempio n. 10
0
 public Bill Get(int id)
 {
     return(billRepository.Get(id));
 }