Exemple #1
0
        public IActionResult Index()
        {
            _billRepository.Add(new Bill {
                Date        = DateTime.Now,
                Value       = 12.2m,
                Description = "Teste"
            });

            _billRepository.Add(new Bill {
                Date        = DateTime.Now,
                Value       = 12.2m,
                Description = "Teste"
            });

            _billRepository.Add(new Bill {
                Date        = DateTime.Now,
                Value       = 12.2m,
                Description = "Teste"
            });

            _billRepository.Add(new Bill {
                Date        = DateTime.Now,
                Value       = 12.2m,
                Description = "Teste"
            });

            var bills = _billRepository.List();

            return(View(bills));
        }
        public async Task <IActionResult> AddBillRecord([FromBody] Bill bill)
        {
            billRepository.Add(bill);
            await unitOfWork.CompleteAsync();

            return(Ok(bill));
        }
        public async Task Handle(BillingDateReachedIntegrationEvent evt, CancellationToken cancellationToken)
        {
            var bill = new Bill(evt.ContractId, evt.TemplateId, evt.CustomerId, evt.TenementId, evt.BillingPeriodStart, evt.BillingPeriodEnd);

            _billRepository.Add(bill);
            await _billRepository.UnitOfWork.SaveChangesAsync(cancellationToken);
        }
Exemple #4
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 #5
0
        public ICommandResult Execute(CreateOrUpdateBillCommand command)
        {
            var bill = new BillModel
            {
                Id               = command.Id,
                BillNumber       = command.BillNumber,
                Amount           = command.Amount,
                BillDate         = command.BillDate,
                Category         = command.Category,
                CreatedBy        = command.CreatedBy,
                CreatedOn        = command.CreatedOn,
                Description      = command.Description,
                DueDate          = command.DueDate,
                IsRecurring      = command.IsRecurring,
                Items            = command.Items,
                LastUpdatedBy    = command.LastUpdatedBy,
                LastUpdatedOn    = command.LastUpdatedOn,
                RecurringSetting = command.RecurringSetting,
                Status           = command.Status,
                Vendor           = command.Vendor
            };

            var entity = ModelFactory.Create(bill);

            if (string.IsNullOrEmpty(command.Id))
            {
                if (entity.BillItems != null)
                {
                    foreach (var item in entity.BillItems)
                    {
                        _billItemRepository.Add(item);
                    }
                }

                _billRepository.Add(entity);
                _unitOfWork.Commit();
            }
            else
            {
                if (entity.BillItems != null)
                {
                    foreach (var item in entity.BillItems)
                    {
                        _billItemRepository.Update(item);
                    }
                }

                _billRepository.Update(entity);
                _unitOfWork.Commit();
            }

            return(new CommandResult(true));
        }
Exemple #6
0
        public IActionResult Create(BillCreateViewModel vm)
        {
            Bill bill = new Bill(vm.Client, vm.Info)
            {
                Items = vm.Items
            };

            _billRepository.Add(bill);
            _billRepository.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
Exemple #7
0
        public void Create(BillModel billVm)
        {
            var order        = billVm.ToBill();
            var orderDetails = billVm.BillDetails;

            foreach (var detail in orderDetails)
            {
                var product = _productRepository.Queryable().Where(p => p.Id == detail.ProductId).FirstOrDefault();
                detail.Price = product.Price;
            }
            order.BillDetails = orderDetails;
            _billRepository.Add(order);
        }
Exemple #8
0
        public void Create(BillViewModel billVm)
        {
            var order        = Mapper.Map <BillViewModel, Bill>(billVm);
            var orderDetails = Mapper.Map <List <BillDetailViewModel>, List <BillDetail> >(billVm.BillDetails);

            foreach (var detail in orderDetails)
            {
                var product = _productRepository.FindById(detail.ProductId);
                detail.Price = product.Price;
            }
            order.BillDetails = orderDetails;
            _orderRepository.Add(order);
        }
Exemple #9
0
        /// <summary>
        /// 新增一笔Bill信息
        /// </summary>
        /// <param name="bill"></param>
        /// <returns></returns>
        public IHttpActionResult Post([FromBody] BillModel bill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (bill == null)
            {
                return(InternalServerError(new ArgumentNullException("Bills 信息为空")));
            }
            var _currentUser = User.Identity.GetUserId();
            var dateNow      = DateTime.UtcNow;

            bill.Id            = Guid.NewGuid().ToString();
            bill.CreatedBy     = User.Identity.GetUserId();
            bill.CreatedOn     = dateNow;
            bill.LastUpdatedOn = dateNow;
            bill.LastUpdatedBy = User.Identity.GetUserId();

            var entity = ModelFactory.Create(bill);

            // remove the navigation object, to stop EF save referenced object. http://msdn.microsoft.com/en-us/magazine/dn166926.aspx
            entity.Category         = null;
            entity.Vendor           = null;
            entity.RecurringSetting = null;

            if (entity.BillItems != null)
            {
                foreach (var item in entity.BillItems)
                {
                    item.BillId = entity.Id;
                    item.Bill   = null;
                    item.Id     = Guid.NewGuid().ToString();
                    _billItemRepo.Add(item);
                }
            }
            _billRepo.Add(entity);
            try
            {
                _unitOfWork.Commit();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                return(InternalServerError(dbEx));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(Created("/bill/" + bill.Id, bill));
        }
Exemple #10
0
        public void Create(BillViewModel billVm)
        {
            var bill        = _mapper.Map <Bill>(billVm);
            var billDetails = _mapper.Map <List <BillDetailViewModel>, List <BillDetail> >(billVm.BillDetails);

            foreach (var detail in billDetails)
            {
                var product = _productRepository.FindById(detail.ProductId);
                detail.Price = product.Price;
            }
            bill.BillDetails = billDetails;

            _billRepository.Add(bill);
        }
Exemple #11
0
        public void Bill_Create_Test()
        {
            Bill bill = new Bill();

            bill.CustomerName = "Test bill";
            bill.CreatedDate  = DateTime.Now;
            bill.CreatedBy    = "Test";
            bill.Content      = "Trung rong hap sa";
            bill.Status       = true;
            var result = billRepository.Add(bill);

            unitOfWork.Commit();
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.ID);
        }
Exemple #12
0
        public void Create(BillViewModel billViewModel)
        {
            billViewModel.OrderDate = DateTime.Now;
            //Mapping to order and order details domain
            var order        = Mapper.Map <BillViewModel, Bill>(billViewModel);
            var orderDetails = Mapper.Map <List <BillDetailViewModel>, List <BillDetail> >(billViewModel.BillDetails);

            foreach (BillDetail detail in orderDetails)
            {
                var product = _productRepository.FindById(detail.ProductId);
                detail.Price = product.Price;
            }
            order.BillDetails = orderDetails;
            _orderRepository.Add(order);
        }
        public async Task AddMoneyAsync(int billValue, int quantity)
        {
            var billFromDb = await _billRepository.GetByValueAsync(billValue);

            if (billFromDb == null)
            {
                var newBill = new Bill {
                    Value = billValue, Quantity = quantity
                };
                _billRepository.Add(newBill);
            }
            else
            {
                billFromDb.Quantity += quantity;
            }
            _billRepository.SaveChanges();
        }
Exemple #14
0
        public async Task <ValidationResult> Insert(List <Bill> billList)
        {
            BillValidation   billValidation   = new BillValidation();
            ValidationResult validationResult = new ValidationResult();
            Bill             billReturn       = new Bill();

            foreach (var bill in billList)
            {
                validationResult = billValidation.Validate(bill);

                if (validationResult.IsValid)
                {
                    billReturn = await Task.Run(() => _billRepository.Add(bill));
                }
            }

            return(validationResult);
        }
Exemple #15
0
        public void CreateBill(BillViewModel billViewModel)
        {
            try
            {
                var bill        = Mapper.Map <BillViewModel, Bill>(billViewModel);
                var billDetails = Mapper.Map <List <BillDetailViewModel>, List <BillDetail> >(billViewModel.BillDetails.ToList());
                foreach (var item in billDetails)
                {
                    var product = _productRepository.FindById(item.ProductId);
                    item.Price = product.PromotionPrice ?? product.Price;
                }

                bill.BillDetails = billDetails;
                _billRepository.Add(bill);
            }
            catch (Exception ex)
            {
            }
        }
Exemple #16
0
        public IActionResult Create([FromBody] Bill item)
        {
            passport = CommonMethod.GetPassport(Request);
            if (item == null)
            {
                return(BadRequest());
            }
            Object addResult = service.Add(passport, item);

            if (addResult.GetType().ToString() == "DgWebAPI.Model.Bill")
            {
                ResultModel result = new ResultModel(true, (Bill)addResult);
                return(new ObjectResult(result));
            }
            else
            {
                return(new ObjectResult(addResult.ToString()));
            }
        }
Exemple #17
0
        /// <summary>
        /// Save a new bill or update bill
        /// </summary>
        /// <param name="billViewModel"></param>
        public void SaveBill(BillViewModel billViewModel)
        {
            Bill bill = Mapper.Map <BillViewModel, Bill>(billViewModel);
            List <BillDetail> BillDetails = new List <BillDetail>();

            foreach (var item in billViewModel.BillDetailViewModel)
            {
                var BillDetail = new BillDetail()
                {
                    ColorId   = item.ColorId,
                    Price     = item.Price,
                    SizeId    = item.SizeId,
                    Quantity  = item.Quantity,
                    ProductId = item.ProductId
                };
                BillDetails.Add(BillDetail);
            }
            bill.BillDetails = BillDetails;
            _billRepository.Add(bill);
        }
Exemple #18
0
        public void addBill(String userId, Guid gameId, String address, String phoneNumber, String cardNumber, String expirationDate, String cvv, int TotalValue)
        {
            Guid userIdGuid = Guid.Empty;

            if (!Guid.TryParse(userId, out userIdGuid))
            {
                throw new Exception("Invalid Guid Format");
            }
            var game = gameRepository.GetGamebyId(gameId);

            billRepository.Add(new Bill()
            {
                Id             = Guid.NewGuid(),
                UserId         = userIdGuid,
                GameId         = gameId,
                Address        = address,
                PhoneNumber    = phoneNumber,
                CardNumber     = cardNumber,
                ExpirationDate = expirationDate,
                CVV            = cvv,
                TotalValue     = (int)game.Price
            });
        }
Exemple #19
0
 //public methods
 public void Add(Bill item)
 {
     _BillRepository.Add(item);
 }
Exemple #20
0
 public void Add(Bill entity)
 {
     _billRepository.Add(entity);
 }
Exemple #21
0
        public void CreateBill(BillDto billDto)
        {
            var bill = billDto.MappingBill();

            billRepository.Add(bill);
        }
Exemple #22
0
 public Bill Add(Bill bill)
 {
     return(_billRepository.Add(bill));
 }
Exemple #23
0
 public void PostBill(Bill bill)
 {
     Repository.Add(bill);
     Repository.Save();
 }