Ejemplo n.º 1
0
        public PublicHouseViewModel Get(int id)
        {
            PublicHouse publicHouseDB = _publicHouseRepository.Get(id);

            var publicHouse = Mapper.Map <PublicHouse, PublicHouseViewModel>(publicHouseDB);

            return(publicHouse);
        }
Ejemplo n.º 2
0
        public async Task Update(PublicHouse item)
        {
            string query = _queryHelper.GenerateUpdateQuery();

            using (var db = new SqlConnection(_connectionString))
            {
                await db.ExecuteAsync(query, item);
            }
        }
Ejemplo n.º 3
0
        public async Task <int> Create(PublicHouse item)
        {
            string query = _queryHelper.GenerateCreateQuery();

            using (var db = new SqlConnection(_connectionString))
            {
                int newRowId = await db.QuerySingleAsync <int>(query, item);

                return(newRowId);
            }
        }
        private TypeHouse Converter(PublicHouse type)
        {
            switch (type)
            {
            case PublicHouse.Dormitory:
                return(TypeHouse.Dormitory);

            case PublicHouse.Departmental:
                return(TypeHouse.Departmental);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
        public async Task <ActualResult <IEnumerable <PublicHouseEmployeesDTO> > > GetAllAsync(string hashIdEmployee, PublicHouse type)
        {
            try
            {
                var id          = _hashIdUtilities.DecryptLong(hashIdEmployee);
                var publicHouse = await _context.PublicHouseEmployees
                                  .Include(x => x.IdAddressPublicHouseNavigation)
                                  .Where(x => x.IdEmployee == id && x.IdAddressPublicHouseNavigation.Type == Converter(type))
                                  .ToListAsync();

                var result = _mapperService.Mapper.Map <IEnumerable <PublicHouseEmployeesDTO> >(publicHouse);
                return(new ActualResult <IEnumerable <PublicHouseEmployeesDTO> > {
                    Result = result
                });
            }
            catch (Exception exception)
            {
                return(new ActualResult <IEnumerable <PublicHouseEmployeesDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception)));
            }
        }