public ActionResult Create()
        {
            var viewModel = new CreateInvoicesByDateReportViewModel
            {
                Paid     = true,
                Approved = true,
                Finished = true
            };

            return(View(viewModel));
        }
        public ActionResult Result(CreateInvoicesByDateReportViewModel model)
        {
            if (model.DateOfApproving == null && model.DateOfCreation == null && model.DateOfPayment == null && model.PaymentPeriod == null)
            {
                this.ModelState.AddModelError("", @KAssets.Resources.Translation.ReportsArea.Reports.MustChooseAtLeastOneDate);
                return(View("Create", model));
            }

            if (!model.DateOfApproving.HasValue)
            {
                model.DateOfApproving = DateTime.MinValue;
            }
            if (!model.DateOfCreation.HasValue)
            {
                model.DateOfCreation = DateTime.MinValue;
            }
            if (!model.DateOfPayment.HasValue)
            {
                model.DateOfPayment = DateTime.MinValue;
            }
            if (!model.PaymentPeriod.HasValue)
            {
                model.PaymentPeriod = DateTime.MinValue;
            }


            var invoices = this.invoiceService.GetAll()
                           .Where(x => x.IsPaid == model.Paid)
                           .Where(x => x.IsApproved == model.Approved)
                           .Where(x => x.Finished == model.Finished);

            if (!this.IsMegaAdmin())
            {
                var userOrg = this.userService.GetUserOrganisationId(this.User.Identity.GetUserId());
                invoices = invoices.Where(x => x.CompiledUser.Site.OrganisationId == userOrg);
            }


            if (model.OrOrAnd)
            {
                invoices = invoices.Where(x =>
                                          (
                                              (model.DateOfApproving.HasValue ? (x.DateOfApproving.ToShortDateString() == model.DateOfApproving.Value.ToShortDateString()) : (false))
                                              ||
                                              (model.DateOfCreation.HasValue ? (x.DateOfCreation.ToShortDateString() == model.DateOfCreation.Value.ToShortDateString()) : (false))
                                              ||
                                              (model.PaymentPeriod.HasValue ? (x.PaymentPeriod.ToShortDateString() == model.PaymentPeriod.Value.ToShortDateString()) : (false))
                                              ||
                                              (model.DateOfPayment.HasValue ? (x.DateOfPayment.ToShortDateString() == model.DateOfPayment.Value.ToShortDateString()) : (false))
                                          )
                                          );
            }
            else
            {
                invoices = invoices.Where(x =>
                                          (
                                              (model.DateOfApproving.HasValue ? (x.DateOfApproving.ToShortDateString() == model.DateOfApproving.Value.ToShortDateString()) : (true))
                                              &&
                                              (model.DateOfCreation.HasValue ? (x.DateOfCreation.ToShortDateString() == model.DateOfCreation.Value.ToShortDateString()) : (true))
                                              &&
                                              (model.PaymentPeriod.HasValue ? (x.PaymentPeriod.ToShortDateString() == model.PaymentPeriod.Value.ToShortDateString()) : (true))
                                              &&
                                              (model.DateOfPayment.HasValue ? (x.DateOfPayment.ToShortDateString() == model.DateOfPayment.Value.ToShortDateString()) : (true))
                                          )
                                          );
            }

            var viewModel = invoices.ToList()
                            .ConvertAll(x =>
                                        new InvoiceListViewModel
            {
                Id            = x.Id,
                InvoiceNumber = x.Number,
                RecipientMOL  = x.RecipientMOL
            });

            return(View(viewModel));
        }