I tried to create a list page similar to the example in the sample like get Tasks, I did exactly similar way with different entity, not sure my dynamic web api service is not invoking from my js file. Here is the sample code. Not sure where I am going wrong. My Html file is loading with lists empty, do we need to have an y other settings apart from inheriting from IApplicationService? Please suggest me where I am missing, it is wasting time and making me feel wrong about this framework, this is an excellent framework which I liked the idea very well.
Js File
(function () { var app = angular.module('app');
var controllerId = 'sts.views.jobLocation.locationsList';
//var controllerId = 'locationsController';
app.controller(controllerId, [
'$scope', '$location', 'abp.services.tasksystem.jobLocation',
function ($scope, $location, jobLocationService) {
var vm = this;
//vm.localize = abp.localization.getSource('SimpleTaskSystem');
vm.jobLocationList = [];
$scope.selectedState = 0;
vm.filter1 = "test";
//$scope.$watch('selectedState', function (value) {
// vm.refreshJobLocations();
//});
// alert("I am here1");
vm.refreshJobLocations();
vm.refreshJobLocations = function () {
abp.ui.setBusy( //Set whole page busy until getTasks complete
null,
jobLocationService.getLocs({}).success(function (data) {
vm.jobLocationList = data.jobLocationsList;
})
);
};
vm.getLocationsCountText = function () {
return abp.utils.formatString(vm.localize('Xlocations'), vm.jobLocationList.length);
};
}
]);
})();
Cshtml <div class="panel panel-default" ng-controller="sts.views.jobLocation.locationsList as vm">
<br /><br />
<div class="panel-heading" style="position: relative;">
<br />
<div class="row">
<h3 class="panel-title col-xs-6">
TYest
</h3>
</div>
</div>
<ul class="list-group" ng-repeat="jobloc in vm.jobLocationList">
<div class="list-group-item">
<span>{{jobloc.JobLocationID}}</span>
<span> </span>
<span>{{jobloc.JobLocationName}}</span>
</div>
</ul>
</div>
-- Webapi service using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Abp.AutoMapper; using Abp.Application.Services; using Abp.Domain.Repositories; using SimpleTaskSystem.JobLocations.Dtos; using SimpleTaskSystem.JobLocations; using AutoMapper;
namespace SimpleTaskSystem.JobLocations { public class JobLocationAppService : ApplicationService,IJobLocationAppService {
private readonly IRepository<JobLocation> _jobLocationRepository;
public JobLocationAppService(IRepository<JobLocation> jobLocationRepository)
{
_jobLocationRepository = jobLocationRepository;
}
//public JobLocationAppService()
//{
// //_jobLocationRepository = new IJobLocationRepository();
//}
/*
private readonly IJobLocationRepository _jobLocationRepository;
public JobLocationAppService(IJobLocationRepository jobLocationRepository)
{
_jobLocationRepository = jobLocationRepository;
}
*/
public void CreateJobLocation(JobLocationDto jobLocationDTO)
{
Logger.Info("Creating a JobLocation for input: " + jobLocationDTO);
//if (null == jobLocationDTO)
// jobLocationDTO = new JobLocationDto();
JobLocation jobLocation = new JobLocation {
JobLocationID = jobLocationDTO.JobLocationID,
JobLocationName = jobLocationDTO.JobLocationName,
CreatedAt = DateTime.Now,
CreatedBy = "PrahladTest"
};
_jobLocationRepository.Insert(jobLocation);
}
public GetJobLocationsOutput GetLocs(GetJobLocationInput input)
{
Logger.Info("GetJobLocations for filter " );
List<JobLocationDto> jobLocationDtos = new List<JobLocationDto>();
List<JobLocation> jobLocationsList = _jobLocationRepository.GetAll().ToList();
jobLocationDtos = Mapper.Map<List<JobLocationDto>>(jobLocationsList);
return new GetJobLocationsOutput
{
JobLocationsList = Mapper.Map<List<JobLocationDto>>(jobLocationsList)
};
}
}
}
Hi I really liked ASP.NET boiler plate framework, hats off to the framework. I am getting errors when I am using basic thing, please suggest me where I am going wrong. Thanks in advance.
After adding new entity to existing project, did made use of PM> Add-Migration "XXXX" and PM> Update-Database commands.
It successfully created table in the database whatever I specified in entity. I did add in DBContext also. But issue is when I want to use default repository for this, my Repository is null.
Here is my sample code, I made use of existing sample application added a new entity called JobLocation. When I am using while creating new JobLocation getting null in the repository.
Added in DBContext like below public class SimpleTaskSystemDbContext : AbpDbContext { public virtual IDbSet<Task> Tasks { get; set; }
public virtual IDbSet<Person> People { get; set; }
public virtual IDbSet<JobLocation> JobLocs { get; set; }
public SimpleTaskSystemDbContext()
: base("Default")
{
}
public SimpleTaskSystemDbContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
}
//This constructor is used in tests
public SimpleTaskSystemDbContext(DbConnection connection)
: base(connection, true)
{
}
}
public virtual IDbSet<JobLocation> JobLocs { get; set; }