Beispiel #1
0
 public static Transporter ToEntity(this TransporterContract transporter)
 {
     return(new Transporter
     {
         Id = transporter.Id,
         Adress = transporter.Adress,
         City = transporter.City,
         CorporateIdentity = transporter.CorporateIdentity,
         Name = transporter.Name
     });
 }
        public int DoesTransporterExist(TransporterContract transporter)
        {
            var currentTransporter = _uow.TransporterRepository.Get(p => p.CorporateIdentity == transporter.CorporateIdentity)
                                     .LastOrDefault();

            if (currentTransporter == null ||
                !string.Equals(currentTransporter.Name, transporter.Name, StringComparison.CurrentCultureIgnoreCase) ||
                !string.Equals(currentTransporter.Adress, transporter.Adress, StringComparison.CurrentCultureIgnoreCase) ||
                !string.Equals(currentTransporter.City, transporter.City, StringComparison.CurrentCultureIgnoreCase))
            {
                var newTransporter = new Transporter
                {
                    Adress            = transporter.Adress,
                    City              = transporter.City,
                    CorporateIdentity = transporter.CorporateIdentity,
                    Name              = transporter.Name
                };
                _uow.TransporterRepository.CreateOrUpdate(newTransporter);
                return(newTransporter.Id);
            }
            return(transporter.Id);
        }
 public void Post(TransporterContract transporterContract)
 {
     _uow.TransporterRepository.CreateOrUpdate(transporterContract.ToEntity());
 }