public IActionResult GetTariff(string portalName) { if (string.IsNullOrEmpty(portalName)) { return(BadRequest(new { errors = "portalName is required." })); } var tenant = HostedSolution.GetTenant(portalName.Trim()); if (tenant == null) { return(BadRequest(new { errors = "Tenant not found." })); } var tariff = HostedSolution.GetTariff(tenant.TenantId, false); var quota = HostedSolution.GetTenantQuota(tenant.TenantId); return(Ok(new { errors = "", tenant = ToTenantWrapper(tenant), tariff = ToTariffWrapper(tariff, quota) })); }
private IActionResult GetTariff(Tenant tenant) { var tariff = HostedSolution.GetTariff(tenant.TenantId, false); var quota = HostedSolution.GetTenantQuota(tenant.TenantId); return(Ok(new { tenant = CommonMethods.ToTenantWrapper(tenant), tariff = ToTariffWrapper(tariff, quota), })); }
public IActionResult SetTariff(TariffModel model) { if (model == null) { return(BadRequest(new { errors = "PortalName is required." })); } if (!ModelState.IsValid) { var errors = new JArray(); foreach (var k in ModelState.Keys) { errors.Add(ModelState[k].Errors.FirstOrDefault().ErrorMessage); } return(BadRequest(new { errors })); } var tenant = HostedSolution.GetTenant((model.PortalName ?? "").Trim()); if (tenant == null) { return(BadRequest(new { errors = "Tenant not found." })); } var quota = new TenantQuota(tenant.TenantId) { ActiveUsers = 10000, Features = model.Features ?? "", MaxFileSize = 1024 * 1024 * 1024, MaxTotalSize = 1024L * 1024 * 1024 * 1024 - 1, Name = "api", }; if (model.ActiveUsers != default) { quota.ActiveUsers = model.ActiveUsers; } if (model.MaxTotalSize != default) { quota.MaxTotalSize = model.MaxTotalSize; } if (model.MaxFileSize != default) { quota.MaxFileSize = model.MaxFileSize; } HostedSolution.SaveTenantQuota(quota); var tariff = new Tariff { QuotaId = quota.Id, DueDate = model.DueDate != default ? model.DueDate : DateTime.MaxValue, }; HostedSolution.SetTariff(tenant.TenantId, tariff); tariff = HostedSolution.GetTariff(tenant.TenantId, false); quota = HostedSolution.GetTenantQuota(tenant.TenantId); return(Ok(new { errors = "", tenant = ToTenantWrapper(tenant), tariff = ToTariffWrapper(tariff, quota) })); }