54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.InfraStructure;
|
|
using Company.Domain.ZoneAgg;
|
|
using CompanyManagment.App.Contracts.Zone;
|
|
|
|
namespace CompanyManagment.EFCore.Repository;
|
|
|
|
public class ZoneRepository : RepositoryBase<long, Zone>, IZoneRepository
|
|
{
|
|
private readonly CompanyContext _context;
|
|
|
|
public ZoneRepository(CompanyContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
|
|
public List<ZoneViewModel> GetAllZones()
|
|
{
|
|
return _context.ZoneSet.Select(x => new ZoneViewModel()
|
|
{
|
|
ZoneName = x.ZoneName,
|
|
CityId = x.CityId
|
|
|
|
}).ToList();
|
|
}
|
|
|
|
public List<ZoneViewModel> GetZoneListByCityId(int cityId)
|
|
{
|
|
return _context.ZoneSet.Select(x => new ZoneViewModel()
|
|
{
|
|
ZoneName = x.ZoneName,
|
|
CityId = x.CityId
|
|
|
|
}).Where(x=>x.CityId == cityId).ToList();
|
|
}
|
|
|
|
public EditZone GetDetails(long id)
|
|
{
|
|
return _context.ZoneSet.Select(x => new EditZone()
|
|
{
|
|
ZoneName = x.ZoneName,
|
|
CityId = x.CityId
|
|
|
|
}).FirstOrDefault(x=> x.Id == id);
|
|
}
|
|
|
|
public List<ZoneViewModel> Search(ZoneSearchModel searchModel)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |