public bool Insert(List <WAMS_ASSIGNNING_STOCKS> entityDetails, int login) { var srvNew = SIVLastest(""); foreach (var detail in entityDetails) { if (detail.bAssignningStockID != 0 && detail.iModified == 1) { // Update quantity var detailEntity = new WAMS_ASSIGNNING_STOCKS { bAssignningStockID = detail.bAssignningStockID, vStockID = detail.vStockID, vMRF = detail.vMRF, DateStockOut = detail.DateStockOut, dCreated = DateTime.Now, iCreated = login, FlagFile = false }; _customRepository.Update(detailEntity); } else if (detail.bAssignningStockID != 0) { var detailEntity = GetByKey(detail.bAssignningStockID); detailEntity.SIV = srvNew; detailEntity.DateStockOut = detail.DateStockOut; detailEntity.dModified = DateTime.Now; detailEntity.iModified = login; _repository.Update(detailEntity); } else { var detailEntity = new WAMS_ASSIGNNING_STOCKS { vStockID = detail.vStockID, vProjectID = detail.vProjectID, bQuantity = detail.bQuantity, vWorkerID = detail.vWorkerID, SIV = srvNew, vMRF = detail.vMRF, FromStore = detail.FromStore, ToStore = detail.ToStore, iCreated = login, FlagFile = false, Description = detail.Description, DateStockOut = detail.DateStockOut }; _customRepository.Add(detailEntity); } } _customRepository.InsertSiv(srvNew); _unitOfWork.CommitChanges(); return(true); }