Exemplo n.º 1
0
        public async Task <bool> AddPropertiesByCategoryName(AddPropertiesByCategoryNameDto properties)
        {
            properties.PropertyList.ForEach(prop => prop.CategoryId = _context.Category.Single(ct => ct.CategoryName == prop.CategoryName).CategoryId);

            _context.Properties.AddRange(properties.PropertyList.Adapt <List <Property> >());
            await _context.SaveChangesAsync();

            return(await Task.FromResult <bool>(true));
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> AddPropertiesByCategoryName(AddPropertiesByCategoryNameDto properties)
        {
            Response <Entities.Entities.Property> httpResponse = new Response <Entities.Entities.Property>();

            try
            {
                httpResponse.RequestState = true;
                httpResponse.ErrorState   = !await _propertyManager.AddPropertiesByCategoryName(properties);
            }
            catch (Exception ex)
            {
                httpResponse.ErrorState = true;
                httpResponse.ErrorList.Add(ex.Adapt <ApiException>());
            }
            return(httpResponse);
        }