Beispiel #1
0
        public IBill CreateBill(ContactInfo sender, ContactInfoWithAddress receiver, decimal insurance, string goods, string remarks)
        {
            ExceptionHelper.ThrowIfNull(sender, "sender");
            ExceptionHelper.ThrowIfNull(receiver, "receiver");

            goods = (goods ?? String.Empty).Trim();
            remarks = (remarks ?? String.Empty).Trim();

            using (var scope = new System.Transactions.TransactionScope())
            {
                var entity = new Data.Bill
                {
                    bill_date = DateTime.Now,
                    confirmed = _User.Role >= UserRoles.Agent,
                    created = DateTime.Now,
                    creater = _User.Uid,
                    enabled = true,
                    last_state_updated = DateTime.Now,
                    updated = DateTime.Now,
                    state = BillStates.None,
                };
                if (entity.confirmed)
                    entity.confirmer = _User.Uid;

                var bill = new BillService(entity);
                bill.UpdateInfo(sender, receiver);
                bill.UpdateInfo(insurance, goods, remarks);

                _BillRepository.Add(entity);
                _BillRepository.SaveChanges();

                bill.InitTradeNo();
                _BillRepository.SaveChanges();

                scope.Complete();

                return bill;
            }
        }
Beispiel #2
0
 public void UpdateBill(IBill bill, ContactInfo sender, ContactInfoWithAddress receiver, decimal insurance, string goods, string remarks)
 {
     ExceptionHelper.ThrowIfNull(bill, "bill");
     bill.UpdateInfo(sender, receiver);
     bill.UpdateInfo(insurance, goods, remarks);
     _BillRepository.SaveChanges();
 }