Skip to content

Commit

Permalink
Merge pull request #85 from CAUCA-9-1-1/#174_add_list_order
Browse files Browse the repository at this point in the history
#174 add list order
  • Loading branch information
philipperobertgh authored Jul 16, 2018
2 parents 25b60bb + 6dd00d1 commit 2a22446
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 13 deletions.
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/CityLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class CityLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/CityTypeLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class CityTypeLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/CountryLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class CountryLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/CountyLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class CountyLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/RegionLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class RegionLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
10 changes: 10 additions & 0 deletions Survi.Prevention.Models/DataTransfertObjects/StateLocalized.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace Survi.Prevention.Models.DataTransfertObjects
{
public class StateLocalized
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
21 changes: 19 additions & 2 deletions Survi.Prevention.ServiceLayer/Services/CityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -29,6 +30,22 @@ public override List<City> GetList()
.ToList();

return result;
}
}
}

public List<CityLocalized> GetListLocalized(string languageCode)
{
var query =
from city in Context.Cities.AsNoTracking()
where city.IsActive
from localization in city.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new CityLocalized {
Id = city.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
22 changes: 20 additions & 2 deletions Survi.Prevention.ServiceLayer/Services/CityTypeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -29,6 +30,23 @@ public override List<CityType> GetList()
.ToList();

return result;
}
}
}

public List<CityTypeLocalized> GetListLocalized(string languageCode)
{
var query =
from cityType in Context.CityTypes.AsNoTracking()
where cityType.IsActive
from localization in cityType.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new CityTypeLocalized
{
Id = cityType.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
22 changes: 20 additions & 2 deletions Survi.Prevention.ServiceLayer/Services/CountryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -29,6 +30,23 @@ public override List<Country> GetList()
.ToList();

return result;
}
}
}

public List<CountryLocalized> GetListLocalized(string languageCode)
{
var query =
from country in Context.Countries.AsNoTracking()
where country.IsActive
from localization in country.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new CountryLocalized
{
Id = country.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
22 changes: 20 additions & 2 deletions Survi.Prevention.ServiceLayer/Services/CountyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -29,6 +30,23 @@ public override List<County> GetList()
.ToList();

return result;
}
}
}

public List<CountyLocalized> GetListLocalized(string languageCode)
{
var query =
from county in Context.Counties.AsNoTracking()
where county.IsActive
from localization in county.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new CountyLocalized
{
Id = county.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
1 change: 0 additions & 1 deletion Survi.Prevention.ServiceLayer/Services/LaneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ orderby localization.Name

var result = query.ToList()
.Select(lane => new LaneLocalized {Id = lane.Id, Name = new LocalizedLaneNameGenerator().GenerateLaneName(lane.Name, lane.genericDescription, lane.publicDescription, lane.AddWhiteSpaceAfter)})
.Take(30)
.ToList();

return result;
Expand Down
22 changes: 20 additions & 2 deletions Survi.Prevention.ServiceLayer/Services/RegionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -29,6 +30,23 @@ public override List<Region> GetList()
.ToList();

return result;
}
}
}

public List<RegionLocalized> GetListLocalized(string languageCode)
{
var query =
from region in Context.Regions.AsNoTracking()
where region.IsActive
from localization in region.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new RegionLocalized
{
Id = region.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
18 changes: 18 additions & 0 deletions Survi.Prevention.ServiceLayer/Services/StateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Survi.Prevention.DataLayer;
using Survi.Prevention.Models.FireSafetyDepartments;
using Microsoft.EntityFrameworkCore;
using Survi.Prevention.Models.DataTransfertObjects;

namespace Survi.Prevention.ServiceLayer.Services
{
Expand All @@ -30,5 +31,22 @@ public override List<State> GetList()

return result;
}

public List<StateLocalized> GetListLocalized(string languageCode)
{
var query =
from state in Context.States.AsNoTracking()
where state.IsActive
from localization in state.Localizations.DefaultIfEmpty()
where localization.IsActive && localization.LanguageCode == languageCode
orderby localization.Name
select new StateLocalized
{
Id = state.Id,
Name = localization.Name
};

return query.ToList();
}
}
}
6 changes: 6 additions & 0 deletions Survi.Prevention.WebApi/Controllers/CityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public class CityController : BaseCrudController<CityService, City>
public CityController(CityService service) : base(service)
{
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}
6 changes: 6 additions & 0 deletions Survi.Prevention.WebApi/Controllers/CityTypeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public class CityTypeController : BaseCrudController<CityTypeService, CityType>
public CityTypeController(CityTypeService service) : base(service)
{
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}
8 changes: 7 additions & 1 deletion Survi.Prevention.WebApi/Controllers/CountryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ public class CountryController : BaseCrudController<CountryService, Country>
public CountryController(CountryService service) : base(service)
{
}
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}
6 changes: 6 additions & 0 deletions Survi.Prevention.WebApi/Controllers/CountyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ public class CountyController : BaseCrudController<CountyService, County>
public CountyController(CountyService service) : base(service)
{
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}
8 changes: 7 additions & 1 deletion Survi.Prevention.WebApi/Controllers/RegionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ public class RegionController : BaseCrudController<RegionService, Region>
public RegionController(RegionService service) : base(service)
{
}
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}
6 changes: 6 additions & 0 deletions Survi.Prevention.WebApi/Controllers/StateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ public class StateController : BaseCrudController<StateService, State>
public StateController(StateService service) : base(service)
{
}

[HttpGet, Route("localized")]
public ActionResult GetListLocalized([FromHeader] string languageCode)
{
return Ok(Service.GetListLocalized(languageCode));
}
}
}

0 comments on commit 2a22446

Please sign in to comment.