コード例 #1
0
        public ActionResult OwnerStatement(DateTime month, string propertyCode)
        {
            if (!AuthorizationProvider.CanViewStatement())
            {
                return(Forbidden());
            }

            try
            {
                var provider  = new OwnerStatementProvider(_dbContext);
                var viewModel = provider.GetOwnerStatement(month, propertyCode);

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

                // statement owner can only see own statement and summary
                if (AuthorizationProvider.IsStatementOwner() && !AuthorizationProvider.IsStatementAdmin() && !AuthorizationProvider.IsStatementViewer())
                {
                    // TODO: filter the viewModel for the owner account
                }
                return(PartialView("_StatementPartial", viewModel));
            }
            catch
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public JsonResult Update(string model) // parameter must be the same json object defined in parameterMap in kendo's datab source
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var feeModel = JsonConvert.DeserializeObject <PropertyFeeViewModel>(model);

            try
            {
                var dataProvider = new PropertyFeeProvider(_dbContext);
                var entity       = dataProvider.Retrieve(feeModel.PropertyFeeId);
                dataProvider.MapData(feeModel, ref entity);
                dataProvider.Update(entity.PropertyCostId, entity);
                dataProvider.Commit();

                return(Json(feeModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Property Fee {0:d} fails. {1} - {2}", feeModel.PropertyFeeId, ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
コード例 #3
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var feeModel = JsonConvert.DeserializeObject <PropertyFeeViewModel>(model);

            try
            {
                var entity       = new PropertyFee();
                var dataProvider = new PropertyFeeProvider(_dbContext);
                dataProvider.MapData(feeModel, ref entity);
                dataProvider.Create(entity);
                dataProvider.Commit();

                feeModel.PropertyFeeId = entity.PropertyCostId; // set the created Id to return to kendo grid

                return(Json(feeModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Creating Property Fee fails. {0} - {1}", ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }
コード例 #4
0
        public JsonResult Update(string model) // parameter must be the same json object defined in parameterMap in kendo's datab source
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var titleModel = JsonConvert.DeserializeObject <PropertyTitleHistoryRow>(model);

            try
            {
                var dataProvider = new PropertyTitleHistoryProvider(_dbContext);
                var entity       = dataProvider.Retrieve(titleModel.PropertyTitleHistoryId);
                entity.PropertyCode  = titleModel.PropertyCode;
                entity.PropertyTitle = titleModel.PropertyTitle.Substring(0, Math.Min(200, titleModel.PropertyTitle.Length));
                entity.EffectiveDate = ConversionHelper.EnsureUtcDate(titleModel.EffectiveDate);
                dataProvider.Update(entity.PropertyTitleHistoryId, entity);
                dataProvider.Commit();

                return(Json(titleModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Property Title {0:d} fails. {1} - {2}", titleModel.PropertyTitleHistoryId, ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
コード例 #5
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var titleModel = JsonConvert.DeserializeObject <PropertyTitleHistoryRow>(model);

            try
            {
                PropertyTitleHistory titleHistory = new PropertyTitleHistory();
                var dataProvider = new PropertyTitleHistoryProvider(_dbContext);
                titleHistory.PropertyCode  = titleModel.PropertyCode;
                titleHistory.PropertyTitle = titleModel.PropertyTitle.Substring(0, Math.Min(200, titleModel.PropertyTitle.Length));
                titleHistory.EffectiveDate = ConversionHelper.EnsureUtcDate(titleModel.EffectiveDate);
                dataProvider.Create(titleHistory);
                dataProvider.Commit();

                return(Json(titleModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Creating Property Title fails. {0} - {1}", ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }
コード例 #6
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin() && !AuthorizationProvider.IsPricingAdmin())
            {
                return(Forbidden());
            }

            var dataModel = JsonConvert.DeserializeObject <PropertyFantasticMap>(model);

            try
            {
                var map          = new PropertyFantasticMap();
                var dataProvider = new PropertyFantasticMapProvider(_dbContext);
                map.PropertyCode = dataModel.PropertyCode;
                map.ListingId    = dataModel.ListingId;
                dataProvider.Create(map);
                dataProvider.Commit();

                return(Json(dataModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Creating Property Fantastic Map fails. {0} - {1}", ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }
コード例 #7
0
 public ActionResult Index()
 {
     if (!AuthorizationProvider.IsStatementAdmin())
     {
         return(Forbidden());
     }
     return(View(new List <PropertyAccountViewModel>()));
 }
コード例 #8
0
 public ActionResult Index()
 {
     if (!AuthorizationProvider.IsStatementAdmin())
     {
         return(Forbidden());
     }
     return(View());
 }
コード例 #9
0
 public ActionResult Index()
 {
     if (!AuthorizationProvider.IsStatementAdmin())
     {
         return(Forbidden());
     }
     return(RedirectToAction("Index", "PropertyAccount"));
 }
コード例 #10
0
        public JsonResult SyncMap()
        {
            if (!AuthorizationProvider.IsStatementAdmin() && !AuthorizationProvider.IsPricingAdmin())
            {
                return(Forbidden());
            }

            try
            {
                var apiService  = new FantasticService();
                var listingJson = apiService.PropertyListing();
                if (listingJson.total > 0)
                {
                    int changeCount  = 0;
                    var dataProvider = new PropertyFantasticMapProvider(_dbContext);
                    foreach (var map in listingJson.listings)
                    {
                        changeCount += dataProvider.AddOrUpdate(map, false) == true ? 1: 0;
                    }

                    var sync    = 1;
                    var message = "Total of " + changeCount.ToString() + " listing IDs are updated.";
                    if (changeCount > 0)
                    {
                        dataProvider.Commit();
                    }
                    else
                    {
                        sync    = 2;
                        message = "Sync is completed. No change is needed.";
                    }
                    var result = new { sync = sync, message = message };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var result = new { sync = 3, message = "No property is available from Fantastic API service." };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                var result = new { sync = 0, message = ex.Message };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #11
0
        public JsonResult Update(string model) // parameter must be the same json object defined in parameterMap in kendo's datab source
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var accountModel = JsonConvert.DeserializeObject <PropertyAccountViewModel>(model);

            try
            {
                var dataProvider = new PropertyAccountProvider(_dbContext);
                var entity       = dataProvider.Retrieve(accountModel.PropertyAccountId);
                dataProvider.MapData(accountModel, ref entity);
                dataProvider.Update(entity.PropertyAccountId, entity);

                // update properties if changed
                if (dataProvider.IsPayoutMethodLinkChanged(accountModel))
                {
                    // ad-hoc property codes PropertyPayoutMethods replacement
                    var oldPayoutMethods = _dbContext.PropertyAccountPayoutMethods.Where(x => x.PropertyAccountId == entity.PropertyAccountId).ToList();
                    _dbContext.PropertyAccountPayoutMethods.RemoveRange(oldPayoutMethods);
                    foreach (var m in accountModel.SelectedPayoutMethods)
                    {
                        _dbContext.PropertyAccountPayoutMethods.Add(new PropertyAccountPayoutMethod
                        {
                            PropertyAccountId = accountModel.PropertyAccountId,
                            PayoutMethodId    = Int32.Parse(m.Value),
                        });
                    }
                }

                dataProvider.Commit();

                return(Json(accountModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Property Account {0:d} fails. {1} - {2}", accountModel.PropertyAccountId, ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
コード例 #12
0
        public JsonResult RebalanceSummary(SummaryRebalanceTransactionModel model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            try
            {
                var dataProvider = new RebalanceProvider(_dbContext);
                dataProvider.RebalanceSummaryWithNoGroup(model);
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            catch
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                return(Json("fail", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #13
0
        public JsonResult Update(string model) // parameter must be the same json object defined in parameterMap in kendo's datasource
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var clientModel = JsonConvert.DeserializeObject <PayoutMethodViewModel>(model);

            try
            {
                var          dataProvider = new PayoutMethodProvider(_dbContext);
                PayoutMethod entity       = dataProvider.Retrieve(clientModel.PayoutMethodId);
                dataProvider.MapData(clientModel, ref entity);
                dataProvider.Update(entity.PayoutMethodId, entity);

                // update properties if changed
                var propertyToUpdate = dataProvider.PropertyToUpdate(entity.PayoutMethodId, clientModel.SelectedPropertyCodes);
                if (propertyToUpdate != null)
                {
                    _dbContext.PropertyPayoutMethods.RemoveRange(propertyToUpdate);
                    foreach (var newProperty in clientModel.SelectedPropertyCodes)
                    {
                        _dbContext.PropertyPayoutMethods.Add(new PropertyPayoutMethod
                        {
                            PropertyCode   = newProperty.Value,
                            PayoutMethodId = entity.PayoutMethodId
                        });
                    }
                }

                dataProvider.Commit();

                return(Json(clientModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Expense {0:d} fails. {1} - {2}", 0, ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
コード例 #14
0
        public JsonResult Retrieve()
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            try
            {
                var provider         = new PropertyAccountProvider(_dbContext);
                var propertyAccounts = provider.All();
                return(Json(propertyAccounts, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Retrieving Property Accounts fails. {0} - {1}", ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }
コード例 #15
0
        public JsonResult Delete(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var accountModel = JsonConvert.DeserializeObject <PropertyAccountViewModel>(model);

            try
            {
                var dataProvider = new PropertyAccountProvider(_dbContext);
                dataProvider.Delete(accountModel.PropertyAccountId);
                dataProvider.Commit();
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(InternalError(string.Format("Delete Property Account {0:d} fails.", accountModel.PropertyAccountId), "fail", ex));
            }
        }
コード例 #16
0
        public JsonResult Delete(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var entity = JsonConvert.DeserializeObject <PayoutMethodViewModel>(model);

            try
            {
                var dataProvider = new PayoutMethodProvider(_dbContext);
                dataProvider.Delete(entity.PayoutMethodId); // will do cascade deletion of relation table
                dataProvider.Commit();
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(InternalError(string.Format("Delete Expense {0:d} fails.", 0), "fail", ex));
            }
        }
コード例 #17
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var accountModel = JsonConvert.DeserializeObject <PropertyAccountViewModel>(model);

            try
            {
                var dataProvider = new PropertyAccountProvider(_dbContext);
                var entity       = new PropertyAccount();
                dataProvider.MapData(accountModel, ref entity);
                dataProvider.Create(entity);
                dataProvider.Commit();                                     // need to commit to get the newly inserted PropertyAccountId

                accountModel.PropertyAccountId = entity.PropertyAccountId; // set the created Id to return to kendo grid

                foreach (var m in accountModel.SelectedPayoutMethods)
                {
                    _dbContext.PropertyAccountPayoutMethods.Add(new PropertyAccountPayoutMethod
                    {
                        PayoutMethodId    = Int32.Parse(m.Value),
                        PropertyAccountId = entity.PropertyAccountId
                    });
                }
                dataProvider.Commit();

                return(Json(accountModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Creating Property Account fails. {1} - {2}", ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
コード例 #18
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var payoutMethodModel = JsonConvert.DeserializeObject <PayoutMethodViewModel>(model);

            try
            {
                var          dataProvider = new PayoutMethodProvider(_dbContext);
                PayoutMethod entity       = new PayoutMethod();
                dataProvider.MapData(payoutMethodModel, ref entity);
                dataProvider.Create(entity);
                dataProvider.Commit();

                payoutMethodModel.PayoutMethodId = entity.PayoutMethodId; // set the created Id to return to kendo grid

                foreach (var m in payoutMethodModel.SelectedPropertyCodes)
                {
                    _dbContext.PropertyPayoutMethods.Add(new PropertyPayoutMethod
                    {
                        PayoutMethodId = entity.PayoutMethodId,
                        PropertyCode   = m.Value,
                    });
                }
                dataProvider.Commit();

                return(Json(payoutMethodModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Expense {0:d} fails. {1} - {2}", 0, ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }