summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Repository.Logic/RestricaoUsuarioCamposRelatoriosRepository.cs
blob: 12ab57416cb6b7823195150ebae2f2998254d285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using AutoMapper;
using Gestor.Infrastructure.Entities.Seguros;
using Gestor.Infrastructure.Mappers;
using Gestor.Infrastructure.Repository.Generic;
using Gestor.Infrastructure.Repository.Interface;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Model.Domain.Seguros;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Gestor.Infrastructure.Repository.Logic
{
	public class RestricaoUsuarioCamposRelatoriosRepository : GenericRepository<RestricaoUsuarioCamposRelatoriosDb>, IRestricaoUsuarioCamposRelatoriosRepository
	{
		private readonly GenericUnitOfWork _unitOfWork;

		public RestricaoUsuarioCamposRelatoriosRepository(GenericUnitOfWork unitOfWork) : base(unitOfWork.Session)
		{
			this._unitOfWork = unitOfWork;
		}

		public List<RestricaoUsuarioCamposRelatorios> FindByUsuario(long id)
		{
			List<RestricaoUsuarioCamposRelatoriosDb> list = this._unitOfWork.Session.CreateQuery(string.Format("from RestricaoUsuarioCamposRelatoriosDb WHERE Usuario = {0}", id)).List<RestricaoUsuarioCamposRelatoriosDb>().ToList<RestricaoUsuarioCamposRelatoriosDb>();
			return ApplicationMapper.Mapper.Map<List<RestricaoUsuarioCamposRelatoriosDb>, List<RestricaoUsuarioCamposRelatorios>>(list);
		}

		public RestricaoUsuarioCamposRelatorios Merge(RestricaoUsuarioCamposRelatorios restricao)
		{
			RestricaoUsuarioCamposRelatoriosDb restricaoUsuarioCamposRelatoriosDb = ApplicationMapper.Mapper.Map<RestricaoUsuarioCamposRelatorios, RestricaoUsuarioCamposRelatoriosDb>(restricao);
			base.Merge(restricaoUsuarioCamposRelatoriosDb);
			return ApplicationMapper.Mapper.Map<RestricaoUsuarioCamposRelatoriosDb, RestricaoUsuarioCamposRelatorios>(restricaoUsuarioCamposRelatoriosDb);
		}

		public RestricaoUsuarioCamposRelatorios SaveOrUpdate(RestricaoUsuarioCamposRelatorios restricao)
		{
			RestricaoUsuarioCamposRelatoriosDb restricaoUsuarioCamposRelatoriosDb = ApplicationMapper.Mapper.Map<RestricaoUsuarioCamposRelatorios, RestricaoUsuarioCamposRelatoriosDb>(restricao);
			this.SaveOrUpdate(restricaoUsuarioCamposRelatoriosDb);
			return ApplicationMapper.Mapper.Map<RestricaoUsuarioCamposRelatoriosDb, RestricaoUsuarioCamposRelatorios>(restricaoUsuarioCamposRelatoriosDb);
		}
	}
}