Exemplo n.º 1
0
        public int CreateManufacturer(Manufacturer manufacturer)
        {
            manufacturer.Type = manufacturer.GetType().FullName;

            using (TransactionScope ts = new TransactionScope())
            {
                var dataRec = Mapper.Map <Data.Models.Manufacturer>(manufacturer);

                int id = manufacturer.HeartId = dataRec.HeartId = _heartService.CreateHeart(manufacturer);

                _manufacturerGateway.Insert(dataRec);

                ts.Complete();
                return(id);
            }
        }
Exemplo n.º 2
0
        public IEnumerable <Vehicle> Filter(IEnumerable <Vehicle> vehicles, Manufacturer manufacturer)
        {
            var response = new List <Vehicle>();

            foreach (var property in manufacturer.GetType().GetProperties())
            {
                if ((bool)property.GetValue(manufacturer))
                {
                    try
                    {
                        response.AddRange(vehicles.Where(x => x.Manufacturer.ToUpper() != null &&
                                                         x.Manufacturer.ToUpper() == property.Name.ToUpper()));
                    }
                    catch (Exception e)
                    {
                        _logger.Error(e, "Error filtering manufacturer");
                    }
                }
            }
            ;
            return(response);
        }