public void AddRange(IEnumerable <T> entities) { if (entities == null) { throw new ArgumentNullException("entity"); } _repository.AddRange(entities); _unitOfWork.Commit(); }
public int AddRange(IEnumerable <TEntity> entities) { if (entities == null) { throw new NullReferenceException(); } Repository.AddRange(entities); return(UnitOfWork.Commit()); }
public ServiceResponse Create(ServicioDireccíonRequest request) { var dirección = _repository.FindBy(x => x.Cliente_Id == request.Cliente_Id && x.Barrio == request.Barrio && x.Direccion == request.Direccion).FirstOrDefault(); if (dirección != null) { return(new ServiceResponse() { Mensaje = "Dirección ya registrado", Status = false }); } if (request.Direcciónes != null) { dirección = _repository.AddRange(request.Direcciónes.ToList()).FirstOrDefault(); } if (request.Municipio_Id != 0) { dirección = _repository.Add(BuilderFactories.Dirección(request.Barrio, request.Direccion, request.CodigoPostal, request.Municipio_Id, request.Cliente_Id)); } if (dirección == null) { return(new ServiceResponse() { Mensaje = "Usuario fue Creado con exito, (Error al registrar Dirección)", Status = false }); } if (_unitOfWork.Commit() == 1) { return(new ServiceResponse() { Mensaje = "Usuario fue Creado con exito, (Dirección(es) creada(s) con exito)", Status = true }); } else { return(new ServiceResponse() { Mensaje = "Usuario fue Creado con exito, (No se pudo registrar las/la Dirección(es)", Status = false }); } }
public ActionResult SetUpDB() { if (_testRepository.Any()) { _testRepository.RemoveRange(_testRepository.AsQueryable()); } //if (_derbyRepository.Any()) _derbyRepository.RemoveRange(_derbyRepository.AsQueryable()); _unitOfWork.Save(); if (_matcheRepository.Any()) { _matcheRepository.RemoveRange(_matcheRepository.AsQueryable()); } _unitOfWork.Save(); if (_teamRepository.Any()) { _teamRepository.RemoveRange(_teamRepository.AsQueryable()); } if (_playerRepository.Any()) { _playerRepository.RemoveRange(_playerRepository.AsQueryable()); } if (_seasonRepository.Any()) { _seasonRepository.RemoveRange(_seasonRepository.AsQueryable()); } _unitOfWork.Save(); var players = ditmer(); //var players = itMinds(); //var players = ElClásico(); _seasonRepository.Add(new Season()); _playerRepository.AddRange(players.ToList()); _unitOfWork.Save(); //itMindsMatch(); return(RedirectToAction("CreateMatch", "MvcMatch")); }
public void AddRangeTest() { var students = new List <Student> { new Student { FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2010-09-01") }, new Student { FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2013-09-01") }, new Student { FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2012-09-01") }, new Student { FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2011-09-01") }, new Student { FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2013-09-01") }, new Student { FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01") } }; gRep.AddRange(students); gRep.Save(); var result = gRep.GetAll(); Assert.AreEqual(students.Count, result.Count()); }
public IEnumerable <EVoucherCodeDTO> AddRange(IEnumerable <EVoucherCodeDTO> entityDTOs) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <EVoucherCodeDTO, E_VoucherCode>(); }); IMapper mapper = config.CreateMapper(); IEnumerable <E_VoucherCode> entities = mapper.Map <List <EVoucherCodeDTO>, List <E_VoucherCode> >(entityDTOs as List <EVoucherCodeDTO>); entities = _vRepo.AddRange(entities); _unitOfWork.SaveChanges(); config = new MapperConfiguration(cfg => { cfg.CreateMap <E_VoucherCode, EVoucherCodeDTO>(); }); mapper = config.CreateMapper(); var result = mapper.Map <List <E_VoucherCode>, List <EVoucherCodeDTO> >(entities as List <E_VoucherCode>); return(result); }
public virtual IEnumerable <TEntityDTo> AddRange(IEnumerable <TEntityDTo> entityDTOs) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <TEntityDTo, TEntity>(); }); IMapper mapper = config.CreateMapper(); IEnumerable <TEntity> entities = mapper.Map <List <TEntityDTo>, List <TEntity> >(entityDTOs as List <TEntityDTo>); entities = _repo.AddRange(entities); _unitOfWork.SaveChanges(); config = new MapperConfiguration(cfg => { cfg.CreateMap <TEntity, TEntityDTo>(); }); mapper = config.CreateMapper(); var result = mapper.Map <List <TEntity>, List <TEntityDTo> >(entities as List <TEntity>); return(result); }
private void UpdateAddedTaskRefs(IEnumerable <KLEChange> changes, int ownedByOrgnizationUnitId) { var additions = changes.Where(c => c.ChangeType == KLEChangeType.Added).ToList(); _logger.Debug($"Additions: {additions.Count}"); var addedTaskRefs = additions.Select(kleChange => new TaskRef { Uuid = kleChange.Uuid, Type = kleChange.Type, TaskKey = kleChange.TaskKey, Description = kleChange.UpdatedDescription, OwnedByOrganizationUnitId = ownedByOrgnizationUnitId, ActiveFrom = kleChange.ActiveFrom, ActiveTo = kleChange.ActiveTo, } ); _existingTaskRefRepository.AddRange(addedTaskRefs); }
public void AddRange(IEnumerable <TDto> dtoList) { IEnumerable <TModel> modelList = _mapper.Map <IEnumerable <TDto>, List <TModel> >(dtoList); _genericRepository.AddRange(modelList); }
public void AddRange(IEnumerable <TEntity> entities) { _repository.AddRange(entities); _unitOfWork.Commit(); }
public Task <int> InsertAsync(HrPslEmployeeVM entity) { return(Task.Run <int>(() => { //string base64 = entity.Item_Base64_Photo; //entity.Item_Base64_Photo = String.Format(base64); //base64 = base64.Remove(0, base64.IndexOf("base64,") + 7); //entity.EMP_PHOTO = Convert.FromBase64String(base64); HrPslEmployee Employee = new HrPslEmployee { EmployeeCode = entity.EmployeeCode, EmployeeFirstName = entity.EmployeeFirstName, EmployeeFirstNameEn = entity.EmployeeFirstNameEn, EmployeeLastName = entity.EmployeeLastName, EmployeeLastNameEn = entity.EmployeeLastNameEn, DateOfJoin = entity.DateOfJoin, HrPslJobTitleID = entity.HrPslJobTitleID, HrPslBranchID = entity.HrPslBranchID, HrPslDeptartmentID = entity.HrPslDeptartmentID, HrPslContractTypeID = entity.HrPslContractTypeID, HrPslEmployeeStatusID = entity.HrPslEmployeeStatusID, WorkMobileNum = entity.WorkMobileNum, DirectManagerID = entity.DirectManagerID, HrPslEmployeeJobLevelID = entity.HrPslEmployeeJobLevelID, HrPslManagementId = entity.HrPslManagementId, GenderID = entity.GenderID, HrPslMaritalstatusID = entity.HrPslMaritalstatusID, HrPslReligionID = entity.HrPslReligionID, HrPslCountyID = entity.HrPslCountyID, HrPslCityID = entity.HrPslCityID, Address = entity.Address, HrPslNationalityID = entity.HrPslNationalityID, NationalID = entity.NationalID, NationalIdExpData = entity.NationalIdExpData, PassportNo = entity.PassportNo, PassportNoExpDate = entity.PassportNoExpDate, DateOfBirth = entity.DateOfBirth, ResidenceType = entity.ResidenceType, ResidencyNumber = entity.ResidencyNumber, ResidenceExpireDate = entity.ResidenceExpireDate, DrivingLicenseNumber = entity.DrivingLicenseNumber, DrivingLicenseIssueDate = entity.DrivingLicenseIssueDate, DrivingLicenseExpireDate = entity.DrivingLicenseExpireDate, DrivingLicenseIssuer = entity.DrivingLicenseIssuer, DrivingLicenseType = entity.DrivingLicenseType, HasCar = entity.HasCar, GlBankID = entity.GlBankID, BankAccountNumber = entity.BankAccountNumber, HasChronicDisease = entity.HasChronicDisease, ChronicDiseaseDescreption = entity.ChronicDiseaseDescreption, HasInjuries = entity.HasInjuries, InjuriesDescreption = entity.InjuriesDescreption, BloodGroup = entity.BloodGroup }; EmployeeRep.Add(Employee); EmployeeAcademicDegreeRep.AddRange(entity.AcademicDegrees); EmployeeContactsRep.AddRange(entity.Contacts); EmployeeExperienceRep.AddRange(entity.Experiences); EmployeeFamilyDetailsRep.AddRange(entity.FamilyDetails); EmployeeTrainingCourcesRep.AddRange(entity.TrainingCourses); //todo:Remove this after full integration with HR project //AddEmployeeOnHRProjectEmployeeTable(emp); return entity.HrPslEmployeeID; })); }
/// <summary> /// Método para CREAR un rango de objetos/registros en la base de datos. /// </summary> /// <param name="obj">Entidad generica para ser tratado como objeto.</param> /// <returns>Retorna los objetos creados.</returns> public static IEnumerable <T> AddRange(IEnumerable <T> obj) { return(Repo.AddRange(obj)); }
public void AddDataToTable <T>(IGenericRepository <T> genericRepository, IEnumerable <T> data) where T : class { genericRepository.AddRange(data); genericRepository.Save(); }
//public Task<AssetDepreciationDetailsVM> getAssetDepreciationDetails(int AssetOperationMasterId) //{ // return Task.Run(() => // { // return AssetDepreciationDetailsRepo.FilterAsync(p => p.AssetOperationMasterID == AssetOperationMasterId).Result.AsEnumerable() // .Select(p => new AssetDepreciationDetailsVM // { // ID = p.ID, // //Active = p.Active, // AddedBy = p.AddedBy, // AddedOn = p.AddedOn, // AssetDepreciationTypeID = p.AssetDepreciationTypeID, // //Position = p.Position, // AssetLifeSpan = p.AssetLifeSpan, // AssetLifeSpanUnitID = p.AssetLifeSpanUnitID, // AssetOperationMasterID = p.AssetOperationMasterID, // AssetScrapValue = p.AssetScrapValue, // CurrencyID = p.CurrencyID, // CurrencyRate = p.CurrencyRate, // CurrentAssetValue = p.CurrentAssetValue, // DepreciationStartDate = p.DepreciationStartDate, // DepreciationTotals = p.DepreciationTotals, // ExclusionsValue = p.ExclusionsValue, // ExtraValue = p.ExtraValue, // InitialAssetScrapValue = p.InitialAssetScrapValue, // Notes = p.Notes, // NotSubjectToDepreciation = p.NotSubjectToDepreciation, // NotSubjectToRevaluation = p.NotSubjectToRevaluation, // UpdatedBy = p.UpdatedBy, // UpdatedOn = p.UpdatedOn, // }).FirstOrDefault(); // }); //} public Task <int> InsertAsync(AssetOperationMasterVM entity) { return(Task.Run(() => { // insert asset master AssetOperationMaster AssetOperationMaster = new AssetOperationMaster { ID = entity.ID, Code = entity.Code, Number = entity.Number, CurrencyID = entity.CurrencyID, CurrencyRate = entity.CurrencyRate, DepartmentID = entity.DepartmentID, FromAccountID = entity.FromAccountID, AssetOperationTypeID = entity.AssetOperationTypeID, CostCenterID = entity.CostCenterID, DistributorID = entity.DistributorID, OperationStatment = entity.OperationStatment, StartDate = entity.StartDate, SellerAccountID = entity.SellerAccountID, ToAccountID = entity.ToAccountID, AddedBy = entity.AddedBy, AddedOn = DateTime.Now, UpdatedBy = entity.UpdatedBy, UpdatedOn = entity.UpdatedOn, Notes = entity.Notes }; AssetOperationMasterRepo.Add(AssetOperationMaster); // Insert asset operation details List <AssetOperationDetails> AssetOperationDetails = entity.OperationDetails.Select(p => new AssetOperationDetails { AddedBy = p.AddedBy, AddedOn = DateTime.Now, AssetDepreciationSum = p.AssetDepreciationSum, AssetEliminationSum = p.AssetEliminationSum, AssetExtrasSum = p.AssetExtrasSum, AssetMasterID = p.AssetMasterID, FromDepartmentID = p.FromDepartmentID, FromEmployeeID = p.FromEmployeeID, ToDepartmentID = p.ToDepartmentID, ToEmployeeID = p.ToEmployeeID, Value = p.Value, AssetOperationMasterID = AssetOperationMaster.ID, CostCenterID = p.CostCenterID, DistributorID = p.DistributorID, ID = p.ID, Notes = p.Notes, RowNumber = p.RowNumber, SellerAccountID = p.SellerAccountID, UpdatedBy = p.UpdatedBy, UpdatedOn = p.UpdatedOn, }).ToList(); AssetOperationDetailsRepo.AddRange(AssetOperationDetails); if (AssetOperationMaster.AssetOperationTypeID == 7) { ChangeAssetMasterLocations(entity.OperationDetails); } else if (AssetOperationMaster.AssetOperationTypeID == 10) { SetAssignedAssetsAsReceived(entity.OperationDetails); } return AssetOperationMaster.ID; })); }
public static Task AddRangeAsync <TEntity>(this IGenericRepository @this, IEnumerable <TEntity> entities) where TEntity : class { @this.AddRange(entities); return(@this.SaveChangesAsync()); }