コード例 #1
0
        public async Task <Pager <CustomerListViewModel> > GetDraftCustomers([FromQuery] InvoiceDraftFilterViewModel model)
        {
            var constructor = await _businessManager.GetConstructorInvoice(model.ConstructorId ?? 0);

            var constructors = await _businessManager.GetConstructorInvoices(constructor.CompanyId, constructor.Date);

            constructors = constructors.Where(x => x.SearchCriteriaId == constructor.SearchCriteriaId).ToList();

            var invoices = await _businessManager.GetInvoiceDraft(constructors.Select(x => x.Id).ToArray());

            var customers = await _businessManager.GetCustomers(constructor);

            customers = customers.Where(x => !invoices.Any(y => y.CustomerId == x.Id)).ToList();
            var count = customers.Count();

            customers = customers.Skip(model.Offset).Take(model.Limit).ToList();

            if (customers.Count == 0)
            {
                return(new Pager <CustomerListViewModel>(new List <CustomerListViewModel>(), 0, model.Offset, model.Limit));
            }

            var page = (model.Offset + model.Limit) / model.Limit;

            var result = _mapper.Map <List <CustomerListViewModel> >(customers);

            return(new Pager <CustomerListViewModel>(result, count, page, model.Limit));
        }
コード例 #2
0
ファイル: CompanyController.cs プロジェクト: anrmk/account-wa
        // GET: Company/Details/5
        public async Task <IActionResult> Details(long id)
        {
            var item = await _companyBusinessManager.GetCompany(id);

            if (item == null)
            {
                return(NotFound());
            }
            var customers = await _businessManager.GetCustomers(item.Customers.Select(x => x.Id).ToArray());

            ViewBag.Customers = customers;

            return(View(_mapper.Map <CompanyViewModel>(item)));
        }
コード例 #3
0
        public async Task <IActionResult> View(long id)
        {
            var constructor = await _businessManager.GetConstructorInvoice(id);

            var summaryRange = await _companyBusinessManager.GetSummaryRange(constructor.SummaryRangeId);

            ViewBag.SummaryRange = $"{summaryRange.From} - {summaryRange.To}";

            var searchCriteria = await _businessManager.GetInvoiceConstructorSearchCriteria(constructor.SearchCriteriaId);

            ViewBag.SearchCriteria = _mapper.Map <InvoiceConstructorSearchViewModel>(searchCriteria);

            if (searchCriteria.Group == CustomerGroupType.OnlyNew)
            {
                ViewBag.CreatedDate = $"{constructor.Date.FirstDayOfMonth().ToString("MM/dd/yyyy")} - {constructor.Date.LastDayOfMonth().ToString("MM/dd/yyyy")}";
            }
            else if (searchCriteria.Group == CustomerGroupType.ExcludeNew)
            {
                ViewBag.CreatedDate = $"None - {constructor.Date.AddMonths(-1).LastDayOfMonth().ToString("MM/dd/yyyy")}";
            }
            else if (searchCriteria.Group == CustomerGroupType.All)
            {
                ViewBag.CreatedDate = $"None - {constructor.Date.LastDayOfMonth().ToString("MM/dd/yyyy")}";
            }

            var tags = await _businessManager.GetCustomerTags();

            ViewBag.Tags = string.Join(',', tags.Where(x => searchCriteria.TagsIds.Contains(x.Id)).Select(x => x.Name));

            var types = await _businessManager.GetCustomerTypes();

            ViewBag.Types = string.Join(',', types.Where(x => searchCriteria.TypeIds.Contains(x.Id)).Select(x => x.Name));

            var constructors = await _businessManager.GetConstructorInvoices(constructor.CompanyId, constructor.Date);

            constructors = constructors.Where(x => x.SearchCriteriaId == constructor.SearchCriteriaId).ToList();

            var invoices = await _businessManager.GetInvoiceDraft(constructors.Select(x => x.Id).ToArray());

            ViewBag.Invoices = invoices.Count();

            var customers = await _businessManager.GetCustomers(constructor);

            ViewBag.Customers = customers.Count();

            var model = _mapper.Map <InvoiceConstructorViewModel>(constructor);

            if (IsAjaxRequest)
            {
                return(PartialView(model));
            }
            else
            {
                return(View(model));
            }
        }
コード例 #4
0
        public async Task <IActionResult> Create()
        {
            Random rd = new Random();

            byte[] bytes = new byte[4];
            rd.NextBytes(bytes);

            var customers = await _businessManager.GetCustomers();

            ViewBag.Customers = customers.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            var paymentModel = new PaymentViewModel()
            {
                No   = BitConverter.ToString(bytes).Replace("-", ""),
                Date = DateTime.Now
            };

            return(View(paymentModel));
        }
コード例 #5
0
        public async Task <ActionResult> Create(InvoiceViewModel model)
        {
            try {
                if (ModelState.IsValid)
                {
                    var item = await _businessManager.CreateInvoice(_mapper.Map <InvoiceDto>(model));

                    if (item == null)
                    {
                        return(BadRequest());
                    }

                    return(RedirectToAction(nameof(Index)));
                }
            } catch (Exception er) {
                _logger.LogError(er, er.Message);
            }

            var companies = await _companyBusinessManager.GetCompanies();

            ViewBag.Companies = companies.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            if (model.CompanyId != null)
            {
                var customers = await _businessManager.GetCustomers(model.CompanyId ?? 0);

                ViewBag.Customers = customers.Select(x => new SelectListItem()
                {
                    Text = x.Name, Value = x.Id.ToString()
                }).ToList();
            }

            return(View(model));
        }
コード例 #6
0
        public async Task <List <CustomerListViewModel> > GetCustomersByCompanyId(long id)
        {
            var result = await _businessManager.GetCustomers(id);

            return(_mapper.Map <List <CustomerListViewModel> >(result));
        }