Пример #1
0
        public async Task <TenantDetails> GetAsync(TenantDetails tenant)
        {
            using (_logger.BeginScope("GraphExtensions:Get"))
            {
                var http = await _graph.GetClientAsync();

                var resp = await http.SendAsync(new HttpRequestMessage(HttpMethod.Get, $"{Graph.BaseUrl}groups/{tenant.id}/extensions/{propName}/"));

                if (resp.IsSuccessStatusCode)
                {
                    var json = await resp.Content.ReadAsStringAsync();

                    var result = JObject.Parse(json);
                    tenant.identityProvider = result["identityProvider"]?.Value <string>();
                    tenant.directoryId      = result["tenantId"]?.Value <string>();
                    if (result.ContainsKey("requireMFA"))
                    {
                        tenant.requireMFA = result["requireMFA"].Value <bool>();
                    }
                    if (result.ContainsKey("allowSameIssuerMembers"))
                    {
                        tenant.allowSameIssuerMembers = result["allowSameIssuerMembers"].Value <bool>();
                    }
                }
                return(tenant);
            }
        }
Пример #2
0
        public async Task <IActionResult> Get()
        {
            var  id = User.FindFirst("appTenantId").Value;
            Guid guid;

            if (!Guid.TryParse(id, out guid))
            {
                return(BadRequest("Invalid id"));
            }
            var http = await _graph.GetClientAsync();

            try
            {
                var json = await http.GetStringAsync($"{Graph.BaseUrl}groups/{id}");

                var result = JObject.Parse(json);
                var tenant = new TenantDetails()
                {
                    id          = id,
                    name        = result["displayName"].Value <string>(),
                    description = result["description"].Value <string>(),
                };
                await _ext.GetAsync(tenant);

                return(new JsonResult(tenant));
            } catch (HttpRequestException)
            {
                return(NotFound());
            }
        }
Пример #3
0
        public async Task <bool> CreateAsync(TenantDetails tenant)
        {
            var http = await _graph.GetClientAsync();

            var resp = await http.PostAsync(
                $"{Graph.BaseUrl}groups/{tenant.id}/extensions",
                new StringContent(ToJson(tenant).ToString(), System.Text.Encoding.UTF8, "application/json"));

            return(resp.IsSuccessStatusCode);
        }
Пример #4
0
    protected TenantDetails CreateTenantDetails(Tenant tenant)
    {
        Transform newDetailsTransform = GameObjectPool
                                        .Instantiate("TenantDetails", Vector3.zero);

        newDetailsTransform.SetParent(content);
        newDetailsTransform.SetAsLastSibling();
        TenantDetails newDetails = newDetailsTransform.GetComponent <TenantDetails>();

        newDetails.Init(buildingManagementDashboard, SelectedBuilding, tenant);
        details.Add(newDetails);
        return(newDetails);
    }
Пример #5
0
        public async Task <ActionResult> Edit([Bind("Name,LongName, IsAADTenant, IdPDomainName, RequireMFA")] TenantDetails tenant)
        {
            try
            {
                var http = await _rest.GetClientAsync();

                var json = await http.PutAsync(
                    $"{RESTService.Url}/tenant/oauth2/",
                    new StringContent(JObject.FromObject(tenant).ToString(), Encoding.UTF8, "application/json"));

                return(RedirectToAction(nameof(Edit)));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #6
0
        private JObject ToJson(TenantDetails tenant, bool withHeader = true)
        {
            var ext = new
            {
                requireMFA             = false,
                identityProvider       = tenant.identityProvider,
                tenantId               = tenant.directoryId,
                allowSameIssuerMembers = tenant.allowSameIssuerMembers,
            };
            var extStr  = JsonConvert.SerializeObject(ext);
            var extJson = JObject.Parse(extStr);

            if (withHeader)
            {
                extJson.AddFirst(new JProperty("extensionName", propName));
                extJson.AddFirst(new JProperty("@odata.type", "#microsoft.graph.openTypeExtension"));
            }
            return(extJson);
        }
Пример #7
0
        public async Task <bool> UpdateAsync(TenantDetails tenant)
        {
            var http = await _graph.GetClientAsync();

            var req  = new HttpRequestMessage(HttpMethod.Get, $"{Graph.BaseUrl}groups/{tenant.id}/extensions/{propName}");
            var resp = await http.SendAsync(req);

            if (resp.StatusCode == System.Net.HttpStatusCode.NotFound)
            {
                return(await CreateAsync(tenant));
            }
            var json = ToJson(tenant);

            resp = await http.PatchAsync(
                $"{Graph.BaseUrl}groups/{tenant.id}/extensions/{propName}",
                new StringContent(ToJson(tenant, false).ToString(), System.Text.Encoding.UTF8, "application/json"));

            return(resp.IsSuccessStatusCode);
        }
Пример #8
0
        public async Task <IActionResult> Put([FromBody] TenantDetails tenant)
        {
            using (_logger.BeginScope("PUT tenant"))
            {
                var tenantId = User.FindFirstValue("appTenantId");
                if (tenantId == null)
                {
                    return(null);
                }
                if (string.IsNullOrEmpty(tenant.name))
                {
                    return(BadRequest("Invalid parameters"));
                }
                tenant.id = tenantId;
                var http = await _graph.GetClientAsync();

                var groupUrl  = $"{Graph.BaseUrl}groups/{tenantId}";
                var groupData = new
                {
                    description  = tenant.description,
                    mailNickname = tenant.name,
                    displayName  = tenant.name.ToUpper()
                };
                var req = new HttpRequestMessage(HttpMethod.Patch, groupUrl)
                {
                    Content = new StringContent(JObject.FromObject(groupData).ToString(), Encoding.UTF8, "application/json")
                };
                var resp = await http.SendAsync(req);

                if (!resp.IsSuccessStatusCode)
                {
                    return(BadRequest("Update failed"));
                }
                if (!(await _ext.UpdateAsync(tenant)))
                {
                    return(BadRequest("Update of extension attributes failed"));
                }
                return(new OkObjectResult(new { tenantId, name = tenant.name }));
            }
        }
Пример #9
0
        public async Task <ActionResult> Edit()
        {
            var http = await _rest.GetClientAsync();

            var json = await http.GetStringAsync($"{RESTService.Url}/tenant/oauth2");

            var tenant  = JObject.Parse(json);
            var details = new TenantDetails
            {
                Name       = tenant["name"].Value <string>(),
                LongName   = tenant["description"].Value <string>(),
                RequireMFA = tenant["requireMFA"].Value <bool>(),
            };
            var idp = tenant["identityProvider"].Value <string>();

            if (!String.IsNullOrEmpty(idp) && idp.Equals("commonaad"))
            {
                details.OwnerIssuer = tenant["directoryId"].Value <string>();
                details.AllowNoInviteFromSameIssuer = tenant["allowSameIssuerMembers"].Value <bool>();
            }
            return(View(details));
        }
Пример #10
0
        public async Task <ActionResult> Edit([Bind("Name,LongName,RequireMFA")] TenantDetails tenant)
        {
            try
            {
                var http = await _rest.GetClientAsync();

                var details = new
                {
                    name        = tenant.Name,
                    description = tenant.LongName,
                    requireMFA  = tenant.RequireMFA
                };
                var json = await http.PutAsync(
                    $"{RESTService.Url}/tenant/oauth2/",
                    new StringContent(JsonConvert.SerializeObject(details), Encoding.UTF8, "application/json"));

                return(RedirectToAction(nameof(Edit)));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #11
0
        public async Task <IActionResult> Put([FromRoute] Guid id, [FromBody] TenantDetails tenant)
        {
            if (string.IsNullOrEmpty(tenant.Name))
            {
                return(BadRequest("Invalid parameters"));
            }

            var http = await _graph.GetClientAsync();

            var groupUrl  = $"{Graph.BaseUrl}groups/{id.ToString("D")}";
            var groupData = new
            {
                description  = tenant.LongName,
                mailNickname = tenant.Name,
                displayName  = tenant.Name.ToUpper()
            };
            var req = new HttpRequestMessage(HttpMethod.Patch, groupUrl)
            {
                Content = new StringContent(JObject.FromObject(groupData).ToString(), Encoding.UTF8, "application/json")
            };
            var resp = await http.SendAsync(req);

            /*
             * var group = $"{{\"@odata.type\":\"microsoft.graph.openTypeExtension\",\"extensionName\":\"B2CMultiTenant\",\"isAADTenant\":{tenant.IsAADTenant},\"domain\":\"{tenant.IdPDomainName}\"}}";
             * await http.PostAsync(
             *  $"{groupUrl}/extensions",
             *  new StringContent(
             *      group,
             *      System.Text.Encoding.UTF8,
             *      "application/json"));
             */
            if (!resp.IsSuccessStatusCode)
            {
                return(BadRequest("Update failed"));
            }
            return(new OkObjectResult(new { id, name = tenant.Name }));
        }
Пример #12
0
        public async Task <ActionResult> Edit([Bind("Name,LongName, IsAADTenant, IdPDomainName")] TenantDetails tenant)
        {
            var tenantIdClaim = User.FindFirst("appTenantId");

            if (tenantIdClaim != null)
            {
                try
                {
                    var http = await _rest.GetClientAsync();

                    var tenantId = tenantIdClaim.Value;
                    var json     = await http.PutAsync(
                        $"{RESTService.Url}/tenant/oauth2/{tenantId}",
                        new StringContent(JObject.FromObject(tenant).ToString(), Encoding.UTF8, "application/json"));

                    return(RedirectToAction(nameof(Edit)));
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(View());
        }
Пример #13
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text == string.Empty)
                {
                    lblMessage.Text = "Please enter the tenant name.";
                    txtName.Focus();
                    return;
                }
                //if (txtFatherName.Text == string.Empty)
                //{
                //    lblMessage.Text = "Please enter the tenant name.";
                //    txtFatherName.Focus();
                //    return;
                //}

                Tenant obj = new Tenant();

                obj.TenantName = txtName.Text;
                obj.FathersNames = txtFatherName.Text;
                obj.Address = txtAddress.Text;
                obj.ContactNo = txtContactNo.Text;
                obj.IsActive = true;
                obj.OutstandingAmount = 0;
                obj.NoOfShops = tenantDetails.Count;

                int success = 0;

                if (isNewEntry)
                {
                    obj.Id = new Tenant().GetMaxTenantId();
                    obj.Id = obj.Id + 1;
                    success = obj.InsertTenant();
                }
                else
                {
                    obj.Id = int.Parse(lblId.Text);
                    success = obj.UpdateTenant();
                }

                if (success == 1)
                {

                    if (tenantDetails.Count == 1)
                    {
                        //convert unicode to decimal
                        string strMonthlyRent = Encode.HtmlEncode(txtMonthlyRent.Text);
                        decimal decMonthlyRent = 0;
                        try
                        {
                            decMonthlyRent = decimal.Parse(strMonthlyRent);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtMonthlyRent.Focus();
                            return;
                        }

                        string strServcieCharge = Encode.HtmlEncode(txtServiceCharge.Text);
                        decimal decServiceCharge = 0;
                        try
                        {
                            decServiceCharge = decimal.Parse(strServcieCharge);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtServiceCharge.Focus();
                            return;
                        }

                        string strMiscBill = Encode.HtmlEncode(txtMiscBill.Text);
                        decimal decMiscBill = 0;
                        try
                        {
                            decMiscBill = decimal.Parse(strMiscBill);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে বিবিধ বিল ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtMiscBill.Focus();
                            return;
                        }
                        string strAdvance = Encode.HtmlEncode(txtAdvance.Text);
                        decimal decAdvance = 0;
                        try
                        {
                            decAdvance = decimal.Parse(strAdvance);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে অগ্রিম ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtAdvance.Focus();
                            return;
                        }
                        string strPrevDue = Encode.HtmlEncode(txtPrevDue.Text);
                        decimal decPrevDue = 0;
                        try
                        {
                            decPrevDue = decimal.Parse(strPrevDue);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে পূর্ববর্তী বকেয়া ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtPrevDue.Focus();
                            return;
                        }
                        string strYear = Encode.HtmlEncode(txtContractYear.Text);
                        int decYear = 0;
                        try
                        {
                            decYear = int.Parse(strYear);
                        }
                        catch (Exception ex)
                        {
                            Alert.Show("দয়া করে চুক্তির মেয়াদ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                            txtContractYear.Focus();
                            return;
                        }

                        TenantDetails objDetails = tenantDetails.Find(x => x.marketId == int.Parse(ddlMarket.SelectedValue) &&
                           x.shopId == int.Parse(ddlShop.SelectedValue));
                        if (objDetails.marketId == 0)
                            objDetails = new TenantDetails();
                        else
                            tenantDetails.Remove(objDetails);

                        objDetails.marketId = int.Parse(ddlMarket.SelectedValue);
                        objDetails.shopId = int.Parse(ddlShop.SelectedValue);
                        objDetails.marketName = ddlMarket.Text;
                        objDetails.ShopNo = ddlShop.SelectedText;
                        objDetails.contractValidYear = decYear;
                        objDetails.previousDue = decPrevDue;
                        objDetails.monthlyRent = decMonthlyRent;
                        objDetails.serviceCharge = decServiceCharge;
                        objDetails.advance = decAdvance;
                        objDetails.miscBill = decMiscBill;
                        objDetails.contractDate = dtpContractDate.SelectedDate ?? DateTime.Today;
                        if (tenantDetails.Count == 0 || tenantDetails[0].shopId == 0)
                            tenantDetails = new List<TenantDetails>();

                        tenantDetails.Add(objDetails);

                    }
                    //obj = obj.GetTenantById(obj.Id);

                    foreach (TenantDetails tenantDetail in tenantDetails)
                    {
                        ShopeMapping objMapping=new ShopeMapping();
                        objMapping.TenantId = obj.Id;
                        objMapping.MarketId = tenantDetail.marketId;
                        objMapping.ShopeId = tenantDetail.shopId;
                        objMapping.MonthlyRent = tenantDetail.monthlyRent;
                        objMapping.ServiceCharge = tenantDetail.serviceCharge;
                        objMapping.Advance = tenantDetail.advance;
                        objMapping.MiscBill = tenantDetail.miscBill;
                        objMapping.ContractDate = (DateTime) tenantDetail.contractDate;
                        objMapping.ContractValidYear = tenantDetail.contractValidYear;
                        objMapping.PreviousDue = tenantDetail.previousDue;

                        objMapping.Id = new ShopeMapping().GetId(objMapping.TenantId, objMapping.ShopeId);

                        if (objMapping.Id == 0)
                            success = objMapping.InsertShopeMapping();
                        else
                            success = objMapping.UpdateShopeMapping();

                        if (success == 0)
                        {
                            lblMessage.Text ="The tenant information saved successfully, but failed to save shop mapping.";
                            lblMessage.ForeColor = Color.Red;
                            return;
                        }

                    }

                    Alert.Show("Data saved successfully.");

                    lblId.Text = obj.Id.ToString();

                    isNewEntry = false;

                }
            }
            catch (Exception ex)
            {

                Alert.Show(ex.Message);
            }
        }
Пример #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        private void ShowTenantDetails(int id)
        {
            Tenant tenant = new Tenant().GetTenantById(id);

            lblId.Text = tenant.Id.ToString();
            txtName.Text = tenant.TenantName;
            txtAddress.Text = tenant.Address;
            txtContactNo.Text = tenant.ContactNo;
            txtFatherName.Text = tenant.FathersNames;

            tenantDetails = new List<TenantDetails>();

            DataTable dtMapping = new ShopeMapping().GetShopeMappingByTenantId(tenant.Id);
            if (dtMapping.Rows.Count > 0)
            {
                foreach (DataRow row in dtMapping.Rows)
                {
                    TenantDetails _tenantDetails = new TenantDetails();
                    _tenantDetails.Id = int.Parse(row["Id"].ToString());
                    _tenantDetails.marketId = int.Parse(row["marketId"].ToString());
                    _tenantDetails.marketName = row["marketName"].ToString();
                    this.LoadShopDropDown(_tenantDetails.marketId);
                    _tenantDetails.ShopNo = row["shopNo"].ToString();
                    _tenantDetails.advance = (row["Advance"] == DBNull.Value) ? 0 : decimal.Parse(row["Advance"].ToString());
                    _tenantDetails.contractDate = DateTime.Parse(row["contractDate"].ToString());
                    _tenantDetails.contractValidYear = (row["ContractValidYear"] == DBNull.Value) ? 0 : int.Parse(row["ContractValidYear"].ToString());
                    _tenantDetails.monthlyRent = (row["monthlyRent"] == DBNull.Value) ? 0 : decimal.Parse(row["monthlyRent"].ToString());
                    _tenantDetails.previousDue = (row["PreviousDue"] == DBNull.Value) ? 0 : decimal.Parse(row["PreviousDue"].ToString());
                    _tenantDetails.serviceCharge = (row["serviceCharge"] == DBNull.Value) ? 0 : decimal.Parse(row["serviceCharge"].ToString());
                    _tenantDetails.shopId = int.Parse(row["shopeId"].ToString());
                    _tenantDetails.miscBill = (row["miscBill"] == DBNull.Value) ? 0 : decimal.Parse(row["miscBill"].ToString());

                    tenantDetails.Add(_tenantDetails);
                }

                if (tenantDetails.Count == 1)
                {
                    TenantDetails details = tenantDetails[0];
                    ddlMarket.SelectedValue = details.marketId.ToString();
                    this.LoadShopDropDown(int.Parse(ddlMarket.SelectedValue));
                    ddlShop.SelectedValue = details.shopId.ToString();
                    txtMonthlyRent.Text = details.monthlyRent.ToString();
                    txtAdvance.Text = details.advance.ToString();
                    txtServiceCharge.Text = details.serviceCharge.ToString();
                    dtpContractDate.SelectedDate = details.contractDate;
                    txtContractYear.Text = details.contractValidYear.ToString();
                    txtPrevDue.Text = details.previousDue.ToString();
                    txtMiscBill.Text = details.miscBill.ToString();

                    isNewDetailEntry = false;
                    btnAddDetail.Visible = false;
                }
                else
                {
                    btnAddDetail.Visible = true;
                }
            }
            else
            {
                tenantDetails.Add(new TenantDetails());
            }

            this.LoadGridView();
        }
Пример #15
0
        public async Task <IActionResult> Put([FromBody] TenantDetails tenant)
        {
            var tenantId = User.FindFirstValue("appTenantId");

            if (tenantId == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(tenant.Name))
            {
                return(BadRequest("Invalid parameters"));
            }

            var http = await _graph.GetClientAsync();

            var groupUrl  = $"{Graph.BaseUrl}groups/{tenantId}";
            var groupData = new
            {
                description  = tenant.LongName,
                mailNickname = tenant.Name,
                displayName  = tenant.Name.ToUpper()
            };
            var req = new HttpRequestMessage(HttpMethod.Patch, groupUrl)
            {
                Content = new StringContent(JObject.FromObject(groupData).ToString(), Encoding.UTF8, "application/json")
            };
            var resp = await http.SendAsync(req);

            /*
             * var group = $"{{\"@odata.type\":\"microsoft.graph.openTypeExtension\",\"extensionName\":\"B2CMultiTenant\",\"isAADTenant\":{tenant.IsAADTenant},\"domain\":\"{tenant.IdPDomainName}\"}}";
             * await http.PostAsync(
             *  $"{groupUrl}/extensions",
             *  new StringContent(
             *      group,
             *      System.Text.Encoding.UTF8,
             *      "application/json"));
             */
            if (!resp.IsSuccessStatusCode)
            {
                return(BadRequest("Update failed"));
            }
            if (tenant.requireMFA)
            {
                req  = new HttpRequestMessage(HttpMethod.Get, $"https://graph.microsoft.com/beta/groups/{tenantId}/extensions/MT.Props");
                resp = await http.SendAsync(req);

                if (resp.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    var body = "{\"@odata.type\": \"microsoft.graph.openTypeExtension\", \"extensionName\": \"MT.Props\", \"requireMFA\": true }";
                    req = new HttpRequestMessage(HttpMethod.Post, $"https://graph.microsoft.com/beta/groups/{tenantId}/extensions")
                    {
                        Content = new StringContent(body, Encoding.UTF8, "application/json")
                    };
                    resp = await http.SendAsync(req);
                }
            }
            else
            {
                req = new HttpRequestMessage(HttpMethod.Delete, $"https://graph.microsoft.com/beta/groups/{tenantId}/extensions/MT.Props");
                await http.SendAsync(req); /* ignore response, be optimistic! */
            }
            return(new OkObjectResult(new { tenantId, name = tenant.Name }));
        }
Пример #16
0
 public void WhenIAddedTenantDetails()
 {
     Driver.driver.FindElement(By.LinkText("Add Tenant")).Click();
     TenantDetails.Details();
 }
Пример #17
0
        public async Task <IActionResult> Post([FromBody] TenantDetails tenant)
        {
            _logger.LogDebug("Starting POST /tenant");
            if ((User == null) || (!User.IsInRole("ief")))
            {
                return(new UnauthorizedObjectResult("Unauthorized"));
            }
            if ((string.IsNullOrEmpty(tenant.name) || (string.IsNullOrEmpty(tenant.ownerId))))
            {
                return(BadRequest(new { userMessage = "Bad parameters", status = 409, version = 1.0 }));
            }
            tenant.name = tenant.name.ToUpper();
            var http = await _graph.GetClientAsync();

            try
            {
                await http.GetStringAsync($"{Graph.BaseUrl}users/{tenant.ownerId}");
            } catch (HttpRequestException ex)
            {
                return(BadRequest(new { userMessage = "Bad user id", status = 409, version = 1.0 }));
            }
            if ((tenant.name.Length > 60) || !Regex.IsMatch(tenant.name, "^[A-Za-z]\\w*$"))
            {
                return(BadRequest(new { userMessage = "Invalid tenant name", status = 409, version = 1.0 }));
            }
            var resp = await http.GetAsync($"{Graph.BaseUrl}groups?$filter=(displayName eq '{tenant.name}')");

            if (!resp.IsSuccessStatusCode)
            {
                return(BadRequest(new { userMessage = "Unable to validate tenant existence", status = 409, version = 1.0 }));
            }
            var values = JObject.Parse(await resp.Content.ReadAsStringAsync())["value"].Value <JArray>();

            if (values.Count != 0)
            {
                return(new ConflictObjectResult(new { userMessage = "Tenant already exists", status = 409, version = 1.0 }));
            }
            var group = new
            {
                description     = tenant.description,
                mailNickname    = tenant.name,
                displayName     = tenant.name,
                groupTypes      = new string[] { },
                mailEnabled     = false,
                securityEnabled = true,
            };
            var jGroup = JObject.FromObject(group);
            var owners = new string[] { $"{Graph.BaseUrl}users/{tenant.ownerId}" };

            jGroup.Add("*****@*****.**", JArray.FromObject(owners));
            //jGroup.Add("*****@*****.**", JArray.FromObject(owners));
            //  https://docs.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-1.0&tabs=http
            resp = await http.PostAsync(
                $"{Graph.BaseUrl}groups",
                new StringContent(jGroup.ToString(), System.Text.Encoding.UTF8, "application/json"));

            if (!resp.IsSuccessStatusCode)
            {
                return(BadRequest("Tenant creation failed"));
            }
            var json = await resp.Content.ReadAsStringAsync();

            var newGroup = JObject.Parse(json);
            var id       = newGroup["id"].Value <string>();

            // Add extensions (open)
            tenant.id = id;
            tenant.allowSameIssuerMembers = (!String.IsNullOrEmpty(tenant.allowSameIssuerMembersString) && (String.Compare("allow", tenant.allowSameIssuerMembersString) == 0));
            if (!(await _ext.CreateAsync(tenant)))
            {
                return(BadRequest("Tenant extensions creation failed"));
            }
            // add this group to the user's tenant collection
            _logger.LogInformation("Finishing Create tenant");
            return(new OkObjectResult(new { id, roles = new string[] { "admin", "member" }, userMessage = "Tenant created" }));
        }
Пример #18
0
        protected void btnAddDetail_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlMarket.SelectedIndex <= 0)
                {
                    return;
                }
                if (ddlShop.SelectedIndex <= 0)
                {
                    return;
                }

                //convert unicode to decimal
                string strMonthlyRent = Encode.HtmlEncode(txtMonthlyRent.Text);
                decimal decMonthlyRent = 0;
                try
                {
                    decMonthlyRent = decimal.Parse(strMonthlyRent);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtMonthlyRent.Focus();
                    return;
                }

                string strServcieCharge = Encode.HtmlEncode(txtServiceCharge.Text);
                decimal decServiceCharge = 0;
                try
                {
                    decServiceCharge = decimal.Parse(strServcieCharge);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে সার্ভিস চার্জ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtServiceCharge.Focus();
                    return;
                }

                string strMiscBill= Encode.HtmlEncode(txtMiscBill.Text);
                decimal decMiscBill = 0;
                try
                {
                    decMiscBill = decimal.Parse(strMiscBill);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে বিবিধ বিল ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtMiscBill.Focus();
                    return;
                }
                string strAdvance = Encode.HtmlEncode(txtAdvance.Text);
                decimal decAdvance = 0;
                try
                {
                    decAdvance = decimal.Parse(strAdvance);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে অগ্রিম ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtAdvance.Focus();
                    return;
                }
                string strPrevDue = Encode.HtmlEncode(txtPrevDue.Text);
                decimal decPrevDue = 0;
                try
                {
                    decPrevDue = decimal.Parse(strPrevDue);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে পূর্ববর্তী বকেয়া ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtPrevDue.Focus();
                    return;
                }
                string strYear= Encode.HtmlEncode(txtContractYear.Text);
                int decYear= 0;
                try
                {
                    decYear = int.Parse(strYear);
                }
                catch (Exception ex)
                {
                    Alert.Show("দয়া করে চুক্তির মেয়াদ ফিল্ডে শুধুমাত্র নাম্বার প্রবেশ করুন।");
                    txtContractYear.Focus();
                    return;
                }

                TenantDetails obj =tenantDetails.Find(x =>x.marketId == int.Parse(ddlMarket.SelectedValue) &&
                            x.shopId == int.Parse(ddlShop.SelectedValue));
                if(obj.marketId==0)
                    obj=new TenantDetails();
                else
                    tenantDetails.Remove(obj);

                obj.marketId = int.Parse(ddlMarket.SelectedValue);
                obj.shopId = int.Parse(ddlShop.SelectedValue);
                obj.marketName = ddlMarket.Text;
                obj.ShopNo = ddlShop.SelectedText;
                obj.contractValidYear = decYear;
                obj.previousDue = decPrevDue;
                obj.monthlyRent = decMonthlyRent;
                obj.serviceCharge = decServiceCharge;
                obj.advance = decAdvance;
                obj.miscBill = decMiscBill;
                obj.contractDate = dtpContractDate.SelectedDate ?? DateTime.Today;
                if(tenantDetails.Count==0 || tenantDetails[0].shopId==0)
                    tenantDetails=new List<TenantDetails>();

                tenantDetails.Add(obj);

                LoadGridView();

                ClearDetailSection();
                isNewDetailEntry = true;
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
                lblMessage.ForeColor = Color.Red;
            }
        }