Beispiel #1
0
        public async Task <BaseResponse <HotelAttributeViewModel> > FindByIdAsync(int id)
        {
            var entity = await _db.HotelAttributes.FindAsync(id);

            if (entity != null)
            {
                var viewModel = new HotelAttributeViewModel();
                viewModel.InjectFrom(entity);
                return(BaseResponse <HotelAttributeViewModel> .Success(viewModel));
            }
            return(BaseResponse <HotelAttributeViewModel> .NoContent(new HotelAttributeViewModel()));
        }
Beispiel #2
0
        public async Task <BaseResponse <HotelAttributeViewModel> > FindByNameAsync(string attributeName)
        {
            if (string.IsNullOrEmpty(attributeName))
            {
                return(BaseResponse <HotelAttributeViewModel> .BadRequest());
            }
            var entity = await _db.HotelAttributes.FirstOrDefaultAsync(p => p.AttributeName.Equals(attributeName));

            if (entity != null)
            {
                var viewModel = new HotelAttributeViewModel();
                viewModel.InjectFrom(entity);
                return(BaseResponse <HotelAttributeViewModel> .Success(viewModel));
            }
            return(BaseResponse <HotelAttributeViewModel> .NoContent(new HotelAttributeViewModel()));
        }