Base solution for your next web application

Activities of "epayday"

Answer

I wish to create seed data when a new tenant is created. What I am attempting to do is create a set of common records all tenants will start with. After that they can do what they want.

Do I run my seeding code when the DefaultTenantBuilder executes (which I assume runs ONLY when you create a new tenant) ?

If so do I get the newly created Tenant ID from ?

defaultTenant = new MultiTenancy.Tenant(AbpTenantBase.DefaultTenantName, AbpTenantBase.DefaultTenantName);

Just to ensure I am not barking up the wrong tree, here is my code sample.

        public void Create()
        {
            CreateDefaultTenant();

            new InitialStateDataCreator(_context).Create();
        } 
        ............
        
    class InitialStateDataCreator
    {
        readonly string[] stateArray = {"Queensland", "New South Wales", "Australian Capital Territory",
                                        "Victoria", "Tasmania", "South Australia", "Western Australia",
                                        "Northern Territory" };
        private readonly CrazyCatLadyDemoDbContext _context;

        public InitialStateDataCreator(CrazyCatLadyDemoDbContext context)
        {
            _context = context;
        }

        public void Create()
        {
            CreateStateData();
        }

        private void CreateStateData()
        {
            var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName);
            foreach (string state in stateArray)
            {
                var stateToFind = _context.States.FirstOrDefault(p => p.Name == state);
                if (stateToFind == null)
                {
                    _context.States.Add(
                        new State
                        {
                            Name = state,
                            TenantId = defaultTenant.Id
                        });
                }
            }
        }
    }
Question

I found this support post https://support.aspnetzero.com/QA/Questions/3591 with regards to Seeding Tenant Data.

Got the code working but I am confused on how I can seed the data with the correct Tenant ID.

var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == MultiTenancy.Tenant.DefaultTenantName);

The above line of code gives me the default ID of 1.

I know elsewhere you get the current tenant via AbpSession.TenantId but due to my limited knowledge I can't work out how access ApbSession inside my custom code called from DefaultTenantBuilder.cs

Hi, we want to use a copy of the _CreateXxxxxModal.cshtml as an _EditXxxxxModal.cshtml. We will need to populate the modal as it opens with the row data for the row that was selected Id. Allow change s and if the save button is pressed update the data in that row of the database table for that Id.

We are not sure where to start and are concerned of taking the wrong direction causing further delays. Do we start by going to the AppService file and adding an Async function? Not sure how we get the Modal to populate.

Do we use

FindAsync InsertAsync

UpdateAsync

?????????

    //[AbpAuthorize(AppPermissions.Pages_Tenant_PayRate_Edit)]
    //public async Task EditPayRate(EntityDto input)
    //{
    //    var payRate = input.PayRateID;
    //    var payRatedetails = _payRateRepository
    //                        .GetAll()
    //                        .WhereIf(!(payRate.Equals(0)),
    //                                   p => p.PayRateID.Equals(payRate)).ToList();

    //    if (payRatedetails.Count > 0)
    //    {
    //        var entity = await _payRateRepository
    //                                .EpdPayRate
    //                                .FindAsync(entity => entity.SomeId == matchingId);

    //        entity.PropertyA = "something";
    //        entity.PropertyB = 1;
    //        await _payRateRepository.SaveChangesAsync();
    //    }
    //    else
    //    {
    //        var payRateinfo = input.MapTo<PayRate>();
    //        await _payRateRepository.InsertAsync(payRate);
    //    }
    //}

Thanks, e-PayDay.

Question

Hi, we have just started looking at testing our project on Azure. I notice our .Application and .Core folders have their publish buttons grayed out. A procedure of moving the project components as well as the SQL database to Azure and any warning of pitfalls would be appreciated.

Thanks, :D

Question

Hi, I am trying to replicate part of the tutorial PhoneBook in regards to displaying the contents on a page of another table in the database, PayRateType table. In my PayRateTypeAppService class I have the following line of code.

return new ListResultDto<PayRateTypeListDto>(PayRateType.MapTo<List<PayRateTypeListDto>>());

For this line of code I get the following error. Error CS0117 'PayRateType' does not contain a definition for 'MapTo" The equivalent Person class does not appear to contain a definition for "MapTo" either, however this does not create an error? I think there is something going on behind the scene, but I am not sure how / why it works for the phonebook example and not for ours. Thanks,

Question

Hi, for v2.1 we replaced IdInput with EntityDto. However there is still one error remaining as to attachement. Code below [AbpAuthorize(AppPermissions.Pages_Tenant_PhoneBook_DeletePerson)] public async Task DeletePerson(EntityDto input) { await _personRepository.DeleteAsync(input.Id); } Cannot convert from method group to person. Thanks, [attachment=0:3mwr7p2q]Delete Person 17102016 1028.png[/attachment:3mwr7p2q]

Question

Hi, we have downloaded the ASP.NETZero V2.1 and we have attempted to go through the PhoneBook tutorial. We got up to the creating person application service section. ListResultOutput CS0246 - Show potential fixes > Generate class ListResultOutput.

public ListResultOutput<PersonListDto> GetPeople(GetPeopleInput input) { var persons = _personRepository .GetAll() .WhereIf( !input.Filter.IsNullOrEmpty(), p => p.Name.Contains(input.Filter) || p.Surname.Contains(input.Filter) || p.EmailAddress.Contains(input.Filter) ) .OrderBy(p => p.Name) .ThenBy(p => p.Surname) .ToList();

        return new ListResultOutput&lt;PersonListDto&gt;(persons.MapTo&lt;List&lt;PersonListDto&gt;>());
    }

I think the return may be causing the issues? Also, public class PersonAppService : epaydayServiceBase, IPersonAppService CS0738 - Show potential fixes > Implement interface.

I am guessing others are using V2.1. Have other people come across these issues and know why they arise with V2.1?

Thanks,

Showing 1 to 7 of 7 entries