public new RepositoryActionResult <Shared.Models.Planning> Insert(Shared.Models.Planning entity)
        {
            if (entity.Car == null)
            {
                throw new ArgumentException();
            }

            entity.Car = _carRepository.FindSingle(entity.Car.Id);

            if (entity.State == null)
            {
                throw new ArgumentException();
            }

            entity.State = _stateRepository.FindSingle(entity.State.Id);

            _repository.Add(entity);
            var result = _repository.Save();

            if (result > 0)
            {
                return(new RepositoryActionResult <Shared.Models.Planning>(entity, RepositoryActionStatus.Created));
            }

            return(new RepositoryActionResult <Shared.Models.Planning>(entity, RepositoryActionStatus.NothingModified, null));
        }
        public RepositoryActionResult <T> Insert(T entity)
        {
            _repository.Add(entity);
            var result = _repository.Save();

            if (result > 0)
            {
                return(new RepositoryActionResult <T>(entity, RepositoryActionStatus.Created));
            }

            return(new RepositoryActionResult <T>(entity, RepositoryActionStatus.NothingModified, null));
        }
Esempio n. 3
0
 public void Add <TEntity>(TEntity entity) where TEntity : class
 {
     _underlyingContext.Add <TEntity>(entity);
 }
 /// <summary>
 /// Tracks the specified entity in memory and will be inserted into the database when <see cref="IRepositoryContext.SaveChanges" /> is called.
 /// </summary>
 /// <typeparam name="TEntity">The type of the entity.</typeparam>
 /// <param name="entity">The entity.</param>
 public void Add <TEntity>(TEntity entity) where TEntity : class
 {
     _context.Add <TEntity>(entity);
 }
 public void Add(TEntity entity)
 {
     mobjContext.Add(entity);
 }