Base solution for your next web application

Activities of "thobiasxp"

Hi, Good Morning,

Thanks it worked.

Hi, Good Morning,

We have created customer repository by adding reference from core and code is below. If its wrong can u give us sample custom repository code.

public class CountryAppService : stemAppServiceBase, ICountryAppService
    {
        private readonly stemDbContext _spDbContext;

        public CountryAppService(stemDbContext spDbContext)
        {
            _spDbContext = spDbContext;
        };


        public async Task GetDeleteCountry(EntityDto input) 
        {

                var idd = new SqlParameter
                {
                    ParameterName = "TableId",
                    Value = 1
                };

                var list = _spDbContext.Database.SqlQuery<FindDelete>("exec Sp_FindMappedTable @TableId", idd).ToList();

                var count = list.Where(f => f.id == input.Id).ToList();
                if (count.Count() <= 0)
                {

                    await _countryRepository.DeleteAsync(input.Id);
                }
                else
                {
                    throw new UserFriendlyException("Unable to Delete", "Data is being used by another Field");
                }

 }       
}

Hi, Good Morning,

We don't have customer custom repository. we are trying to access database from this code of yours

public class SpDbContext : DbContext
    {
        public SpDbContext()
            : base(GetConnectionString())
        {

        }

        private static string GetConnectionString()
        {
            //Notice that; this logic only works on development time.
            //It is used to get connection string from appsettings.json in the Web project.

            var configuration = AppConfigurations.Get(
                WebContentDirectoryFinder.CalculateContentRootFolder()
                );

            return configuration.GetConnectionString(
                stemConsts.ConnectionStringName
                );
        }

        public SpDbContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {

        }

        public SpDbContext(DbConnection existingConnection)
            : base(existingConnection, false)
        {

        }

        public SpDbContext(DbConnection existingConnection, bool contextOwnsConnection)
            : base(existingConnection, contextOwnsConnection)
        {

        }
    }

and we are calling above class inside our method like this

// Method

public async Task DeleteCity(EntityDto input) { try { using (var context = new SpDbContext()) {

                var idd = new SqlParameter
                {
                    ParameterName = "TableId",
                    Value = 2
                };
                var list = context.Database.SqlQuery&lt;FindDelete&gt;("exec Sp_FindMappedTable @TableId", idd).ToList();

                var count = list.Where(f => f.id == input.Id).ToList();
                if (count.Count() <= 0)
                {

                    await _cityRepository.DeleteAsync(input.Id);
                }
                else
                {
                    throw new UserFriendlyException("Unable to Delete", "Data is being used by another Field");
                }
            }
            }
            catch (Exception ex)
            {

            }
    }

This code is working perfectly fine when we run from the visual studio but when we publish and host it on server we are getting above errors. can you help us sort it out... otherwise is there any other way to call stored procedure.

Thanks

Hi, Good Morning,

This is the error message we are getting in log.

DEBUG 2017-06-08 10:32:17,427 [17   ] osoft.AspNetCore.Routing.Tree.TreeRouter - Request successfully matched the route with name '(null)' and template 'api/services/app/Country/DeleteCountry'.
DEBUG 2017-06-08 10:32:17,431 [17   ] ore.Mvc.Internal.ControllerActionInvoker - Executing action tibs.stem.Countrys.CountryAppService.DeleteCountry (tibs.stem.Application)
INFO  2017-06-08 10:32:17,466 [17   ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method tibs.stem.Countrys.CountryAppService.DeleteCountry (tibs.stem.Application) with arguments (Abp.Application.Services.Dto.EntityDto) - ModelState is Valid
ERROR 2017-06-08 10:32:17,483 [17   ] Mvc.ExceptionHandling.AbpExceptionFilter - Could not find content root folder!
System.ApplicationException: Could not find content root folder!
   at tibs.stem.Web.WebContentDirectoryFinder.CalculateContentRootFolder() in F:\Project Backups\Bafco Backups\bafco 7\aspnet-core\src\tibs.stem.Core\Web\WebContentFolderHelper.cs:line 26
   at tibs.stem.Tenants.Dashboard.SpDbContext.GetConnectionString() in F:\Project Backups\Bafco Backups\bafco 7\aspnet-core\src\tibs.stem.Application\Tenants\Dashboard\SpDbContext.cs:line 27

Thanks

Hi, Good Morning,

Thanks for your help, it worked.

Hi, Good Evening,

[Table("Country")] public class Country : FullAuditedEntity { [Required] public virtual string CountryName { get; set; }

    [Required]
    public virtual string CountryCode { get; set; } 
}

Hi,

Thanks, now its working..

html: its the view..

<div class="row">
                            <div class="col-md-6">
                                <div class="form-group form-md-line-input form-md-floating-label no-hint">
                                    <label>Country</label>
                                    <select #cityCombobox id="yourDropDownElementId" name="city" class="form-control" [(ngModel)]="Selectedcountry" [attr.data-live-search]="true" (change)="doSomethingCountry(Selectedcountry)" jq-plugin="selectpicker" required>
                            <option [value]="SelectedCountryId">{{SelectedCountryName}}</option> 
                            <option *ngFor="let country of countrys" [value]="country.id">{{country.name}}</option> 
                        </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group form-md-line-input form-md-floating-label no-hint">
                                    <label>Company</label>
                                    <select #companyCombobox id="yourDropDownElementId" name="type" class="form-control" [(ngModel)]="Selectedcompany" [attr.data-live-search]="true" (change)="doSomethingcompany(Selectedcompany)" jq-plugin="selectpicker" required>
                            <option [value]="SelectedCompanyId">{{SelectedCompanyName}}</option>
                            <option *ngFor="let company of companys" [value]="company.id" >{{company.name}}</option> 
                         </select>

                                </div>

                            </div>

                        </div>

its **ts:**

    companys: Datadto[] = [];
    countrys: Datadto[] = [];

  doSomethingCountry(data): void {
         
         this._select2Service.getCompany(data).subscribe((result) => {
            if (result.select2data != null) {      
             this.companys = result.select2data;             
            this.vale = result.select2data;
           console.log(this.companys);
         } });
       }

this companys array doest updated in html

Answer

Hi, Good Morning,

For example I have attached screenshot. For that pop up I need direct url access. How can we do it ??

Thanks

Hi, Good Morning,

We have given nullableIddto. Below was the method

"public async Task<GetMileStone> GetMileStoneForEdit(NullableIdDto input)"

Showing 1 to 10 of 37 entries