Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Naman Rawat 3 posts 73 karma points
    Dec 30, 2022 @ 06:33
    Naman Rawat
    0

    Not able to bind data from Umbraco BlockList data by my API method

    Not able to bind data from Umbraco BlockList data by my API method

    This is my code

    public async Task<EmployeeDetailsLayout.EmployeeDetails> GetCompanyEmployeesLayoutpage(GenericContentPage genericContentPage)
            {
                try
                {
    
                    EmployeeDetailsLayout.EmployeeDetails listEmployeeLayout = new EmployeeDetailsLayout.EmployeeDetails();
    
                    if (_umbracoHelperAccessor.TryGetUmbracoHelper(out var umbracoHelper) is false)
                    {
                        throw new Exception("Unable to get Umbraco Helper");
                    }
                    var _node1 = umbracoHelper.Content(1257);
                    // var contentPage = GetGenericContentPage("companyemployees");
                    if (_node1 is not null)
                    {
                        var result = _node1.Value<dynamic>("Employees");
                        //   genericContentPage.BlockList.Select(x => x.GetCorrespondingElementModel()).ToList();
                        foreach (var item in result)
                        {
                            listEmployeeLayout.blockItems.Add(new EmployeeDetailsLayout.BlockItems { EmployeeName = item.Content.EmployeeName, EmployeeEmail = item.Content.EmployeeEmail, EmployeePosition = item.Content.EmployeePosition, EmployeePhone = item.Content.EmployeePhone, EmployeeImage= item.Content }) ;
                        }
                    }
                    // listEmployeeLayout = _mapper.Map<EmployeeDetailsLayout.EmployeeDetails>(listEmployeeLayout);
                    return listEmployeeLayout;
                }
                catch (Exception ex)
                {
    
                    throw ex;
                }
    
    
            }
    
  • Huw Reddick 1702 posts 5999 karma points MVP c-trib
    Dec 30, 2022 @ 12:11
    Huw Reddick
    0

    What is the exact error you are receiving?

  • Naman Rawat 3 posts 73 karma points
    Jan 09, 2023 @ 12:28
    Naman Rawat
    0

    I got the solution. Thank You.

Please Sign in or register to post replies

Write your reply to:

Draft