Пример #1
0
 public void OnGet(int?id)
 {
     Id = id;
     if (id.HasValue)
     {
         var supplier = _supplierRepo.GetById(id.Value);
         Input = new InputModel {
             CompanyName = supplier.CompanyName,
             Balance     = supplier.Balance
         };
     }
     else
     {
         Input = new InputModel();
     }
 }
Пример #2
0
        public IActionResult OnGetPayout(int supplierId)
        {
            var supplier = _supplierRepo.GetById(supplierId);

            if (supplier == null)
            {
                return(NotFound());
            }

            //Create payout and zero out supplier balance
            var payout = new SupplierPayout {
                Amount     = supplier.Balance,
                PayedAt    = DateTime.UtcNow,
                StaffId    = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value),
                SupplierId = supplier.Id
            };

            supplier.Balance = 0;

            //This should be in a tranaction, but we need to ensure the payment is added before we update the balance.
            if (_supplierPayoutRepo.Insert(payout) != 0)
            {
                _supplierRepo.Update(supplier);
            }

            return(RedirectToPage());
        }
Пример #3
0
 public void OnGet(int id)
 {
     Supplier        = _supplierRepo.GetById(id);
     SupplierManager = _mappingRepo.GetSupplierManager(id);
 }