public void Delete(TransporterHeader entity)
 {
     try
     {
         entities.TransporterHeaders.Remove(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void Add(TransporterHeader entity)
 {
     try
     {
         entities.TransporterHeaders.Add(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void Attach(TransporterHeader entity)
 {
     try
     {
         entities.TransporterHeaders.Attach(entity);
         entities.Entry(entity).State = EntityState.Modified;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void Save(TransporterHeader entity)
        {
            try
            {
                TransporterHeader transporterHeader = entities.TransporterHeaders
                                                      .Where(x => x.FarmID == entity.FarmID && x.TransporterID == entity.TransporterID).FirstOrDefault();

                if (transporterHeader != null)
                {
                    entities.Entry(transporterHeader).State = EntityState.Modified;
                }
                else
                {
                    Add(entity);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }