Beispiel #1
0
        public int Add(CarLicencePlateAssociationEntity entity)
        {
            try
            {
                using (var db = new CroceRossaEntities())
                {
                    CarTar carTar = entity.toCarTar();
                    db.CarTar.Add(carTar);
                    db.SaveChanges();

                    return(carTar.CarTarOwnId);
                }
            }
            catch
            {
                return(-1);
            }
        }
Beispiel #2
0
 public int Update(CarLicencePlateAssociationEntity entity)
 {
     try
     {
         using (var db = new CroceRossaEntities())
         {
             CarTar carTar = db.CarTar.First(x => x.CarTarOwnId == entity.Id);
             if (carTar != null)
             {
                 carTar = entity.toCarTar(carTar);
                 db.SaveChanges();
             }
             return(0);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }