public ActionResult OwnerSummary(DateTime month, string payoutMethod)
        {
            if (!AuthorizationProvider.CanViewStatement())
            {
                return(Forbidden(new OwnerStatementSummaryModel()));
            }

            var provider  = new OwnerStatementProvider(_dbContext);
            var viewModel = provider.GetOwnerSummary(month, payoutMethod, false);

            // get the edit freeze flag
            viewModel.IsEditFreezed = (new StatementCompletionProvider(_dbContext)).IsEditFreezed(month);

            return(PartialView("_SummaryPartial", viewModel));
        }
        public JsonResult BackFillOwnerSummaries(DateTime month)
        {
            if (!AuthorizationProvider.IsDataImporter())
            {
                return(Forbidden());
            }

            try
            {
                var summaryProvider = new OwnerStatementProvider(_dbContext);
                var paymentProvider = new OwnerPaymentProvider(_dbContext);
                var payoutMethods   = paymentProvider.All();
                foreach (PayoutMethod method in payoutMethods)
                {
                    if (method.PayoutMethodName != null)
                    {
                        try
                        {
                            var summary = summaryProvider.GetOwnerSummary(month, method.PayoutMethodName, true);
                            var model   = new OwnerStatement();
                            summaryProvider.MapData(summary.ItemTotal, ref model, month, method.PayoutMethodName);

                            var entity = summaryProvider.Retrieve(model);
                            if (entity != null)
                            {
                                model.OwnerStatementId = entity.OwnerStatementId;
                                summaryProvider.Update(model.OwnerStatementId, model);
                            }
                            else
                            {
                                summaryProvider.Create(model);
                            }
                            summaryProvider.Commit();
                        }
                        catch (Exception ex)
                        {
                            return(Json(ex.Message, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
                return(Json("success-Summary", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult PrintSummary(DateTime month, string payoutMethod)
        {
            if (!AuthorizationProvider.CanViewStatement())
            {
                return(Forbidden(new OwnerStatementSummaryModel()));
            }

            try
            {
                var provider  = new OwnerStatementProvider(_dbContext);
                var viewModel = provider.GetOwnerSummary(month, payoutMethod, false);
                viewModel.IsPrint = true;
                return(View(viewModel));
            }
            catch
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(Json(new OwnerStatementSummaryModel(), JsonRequestBehavior.AllowGet));
            }
        }