Ejemplo n.º 1
0
        public JsonResult BackFillStatements(DateTime month)
        {
            if (!AuthorizationProvider.IsDataImporter())
            {
                return(Forbidden());
            }

            try
            {
                var statementProvider = new OwnerStatementProvider(_dbContext);
                var propertyProvider  = new PropertyProvider(_dbContext);
                var properties        = propertyProvider.All();
                foreach (CPL property in properties)
                {
                    if (property.PropertyStatus != "Dead")
                    {
                        try
                        {
                            // create/update owner statement record
                            var model = statementProvider.GetOwnerStatement(month, property.PropertyCode);
                            model.PropertyName = model.PropertyName.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                            var entity = statementProvider.Retrieve(model);
                            if (entity != null)
                            {
                                statementProvider.MapData(model, ref entity);
                                statementProvider.Update(entity.OwnerStatementId, entity);
                            }
                            else
                            {
                                entity = new OwnerStatement();
                                statementProvider.MapData(model, ref entity);
                                statementProvider.Create(entity);
                            }
                            statementProvider.Commit();
                        }
                        catch (Exception ex)
                        {
                            return(Json(ex.Message, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
                return(Json("success-Statement", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }