Exemplo n.º 1
0
 static public void ConfigureServices(string connectionString, IServiceCollection services)
 {
     services.AddDbContext <PoliceStationManagementDbContext>(options =>
                                                              options.UseSqlServer(connectionString))
     .AddTransient <EfPoliceStationManagementDbContext, PoliceStationManagementDbContext>()
     .AddTransient <IPoliceStationRepository, PoliceStationManagementRepository>()
     .AddTransient <IPoliceStationManagement, PoliceStationManagement>()
     .AddTransient <IPoliceStation, PoliceStation>((context) =>
     {
         PoliceStation entity = PoliceStation.CreatePoliceStation("Empty", "Empty", 0, "Empty");
         return(entity);
     });
 }
        public PoliceStationDto Add(string name, string address, uint workers, string chief)
        {
            IPoliceStation newPoliceStation = PoliceStation.CreatePoliceStation(name, address, workers, chief);

            mPoliceStationRepository.Add(newPoliceStation);

            PoliceStationDto newPoliceStationDto = new PoliceStationDto
            {
                Name    = newPoliceStation.Name,
                Id      = newPoliceStation.Id,
                Workers = newPoliceStation.Workers,
                Chief   = newPoliceStation.Chief,
                Address = newPoliceStation.Address
            };

            return(newPoliceStationDto);
        }