Example #1
0
        public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory(
            bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus)
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                Assert.Equal(initialStatus, repo.RetrieveStatus(filename));
                Assert.Equal(existsBeforeRemove, File.Exists(fullpath));

                if (throws)
                {
                    Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename, removeFromWorkdir));
                    Assert.Equal(count, repo.Index.Count);
                }
                else
                {
                    repo.Remove(filename, removeFromWorkdir);

                    Assert.Equal(count - 1, repo.Index.Count);
                    Assert.Equal(existsAfterRemove, File.Exists(fullpath));
                    Assert.Equal(lastStatus, repo.RetrieveStatus(filename));
                }
            }
        }
        public void CanResolveConflictsByRemovingFromTheIndex(
            bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries)
        {
            var path = SandboxMergedTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                Assert.Equal(existsBeforeRemove, File.Exists(fullpath));
                Assert.NotNull(repo.Index.Conflicts[filename]);
                Assert.Equal(0, repo.Index.Conflicts.ResolvedConflicts.Count());

                repo.Remove(filename, removeFromWorkdir);

                Assert.Null(repo.Index.Conflicts[filename]);
                Assert.Equal(count - removedIndexEntries, repo.Index.Count);
                Assert.Equal(existsAfterRemove, File.Exists(fullpath));
                Assert.Equal(lastStatus, repo.RetrieveStatus(filename));

                Assert.Equal(1, repo.Index.Conflicts.ResolvedConflicts.Count());
                Assert.NotNull(repo.Index.Conflicts.ResolvedConflicts[filename]);
            }
        }
        public void Delete()
        {
            using (var context = new MainContext())
            {
                var myRepo = new Repository<Core.Customer>(context);
                TotalCustomersBeforeTestRuns = myRepo.GetAll().Count();

                var allEntities = myRepo.GetAll().ToList();
                if (allEntities.Count > 0)
                {
                    //Find an entity to be removed.
                    var firstClientInTheDb = allEntities.FirstOrDefault();

                    //Check if there is an entity to be removed
                    if (firstClientInTheDb != null)
                    {
                        myRepo.Remove(firstClientInTheDb.Id);
                        myRepo.Save();

                        TotalOfClientsAfterTheTestRuns = myRepo.GetAll().Count();

                        // Check if the total number of entites was reduced by one.
                        Assert.AreEqual(TotalCustomersBeforeTestRuns - 1, TotalOfClientsAfterTheTestRuns);
                    }

                }
            }
        }
Example #4
0
 public void Remove()
 {
     Repository repository = new Repository();
     UserModel user = new UserModel();
     user.Id = 4;
     repository.Remove<UserModel>(user);
 }
Example #5
0
        public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                int count = repo.Index.Count;

                Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
                repo.Remove("1");

                Assert.False(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "1")));
                Assert.Equal(count - 1, repo.Index.Count);
            }
        }
 public void DeleteTest()
 {
     IRepository<Pacient> rep = new Repository<Pacient>(path);
     int i = rep.GetAll().Count();
     rep.Remove(10);
     if (i > 0)
     {
         i--;
     }
     else
     {
         i = 0;
     }
     Assert.AreEqual(rep.GetAll().Count(), i);
 }
        public virtual void Dispose()
        {
            //Clean the database
            using (var context = new MainContext())
            {
                var myRepo = new Repository<Address>(context);

                //Get the Address to be removed.
                MyNewAddress = myRepo.Query(s => s.AddressLine1 == MyNewAddress.AddressLine1).FirstOrDefault();

                if (myRepo.GetAll().Any())
                {
                    myRepo.Remove(MyNewAddress);
                    myRepo.Save();
                }
            }
        }
Example #8
0
        public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/3.txt", "too"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir2/4.txt", "tree"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/5.txt", "for"));
                repo.Stage(Touch(repo.Info.WorkingDirectory, "2/6.txt", "fyve"));

                int count = repo.Index.Count;

                Assert.True(Directory.Exists(Path.Combine(repo.Info.WorkingDirectory, "2")));
                repo.Remove("2", false);

                Assert.Equal(count - 5, repo.Index.Count);
            }
        }
        public void RemoveInstanceTest()
        {
            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**",
            };

            var crate = new Repository("Crate");

            crate.Remove(p);

            var actual = crate.Data.First(c => c.Name == "Person").Type;

            const OperationType expected = OperationType.Removing;

            Assert.AreEqual(expected, actual);
        }
Example #10
0
        static void Main(string[] args)
        {
            IRepository repo = new Repository();
            Product product = new Product(5, 55.5m, "kalipso", "djolan");
            Product product2 = new Product(6, 55.6m, "kalipso", "djolan");
            Product product3 = new Product(7, 55.5m, "kalipso", "djolan");
            Product product4 = new Product(8, 55.5m, "kalipso", "djolan");

            repo.Add(product);
            repo.Add(product2);
            repo.Add(product3);
            repo.Add(product4);

            var productsByTitle = repo.FindByTitle("kalipso");
            var productsBySupplierAndPriceRange = repo.FindBySupplierAndPriceRange("djolan", 55.5m, 55.6m);
            var productByTitleAndPriceRange = repo.FindByTitleAndPriceRange("kalipso", 55.5m, 55.6m);
            var productByPriceRange = repo.FindByPriceRange(55.5m, 55.6m);
            var productsByTitleAndPrice = repo.FindByTitleAndPrice("kalipso", 55.5m);
            var productsBySupplierAndPrice = repo.FindBySupplierAndPrice("djolan", 55.5m);

            bool isSuccessfullyRemoved = repo.Remove(product.Id);
        }
Example #11
0
        private static void Main(string[] args)
        {
            Dc.CreateRepository("ConsoleApp");

            Dc.CreateInstance<Car>(false, "ConsoleApp");
            Dc.CreateInstance<Person>(false, "ConsoleApp");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**",
                Phone = "4325837421"
            };

            var p1 = new Person
            {
                Name = "Alex Cox",
                Age = 54,
                Email = "*****@*****.**",
                Phone = "758467363"
            };

            var p2 = new Person
            {
                Name = "Samanta White",
                Age = 27,
                Email = "*****@*****.**",
                Phone = "8235763294"
            };

            var c = new Car
            {
                Name = "Toyota",
                Model = "Auris",
                Prise = 10000
            };

            var c1 = new Car
            {
                Name = "Chevrolet",
                Model = "Avensis",
                Prise = 7000
            };

            var c2 = new Car
            {
                Name = "BMW",
                Model = "X5",
                Prise = 150000
            };

            var repository = new Repository("ConsoleApp");
            repository.Add(p);
            repository.Add(p1);
            repository.Add(c);
            Dc.SubmitChanges(repository);

            var man = Dc.Select<Person>(repository).First(x => x.Age == 24);
            man.Name = "Updated Name";

            repository.Update(man);
            Dc.SubmitChanges(repository);

            var repositories = Dc.GetRepositories();
            var objects = Dc.GetObjects(repositories.First());
            repository.Remove(man);
            Dc.SubmitChanges(repository);

            repository.Add(p1);
            repository.Add(p2);

            repository.Add(c);
            repository.Add(c1);
            repository.Add(c2);

            var people = Dc.Select<Person>(repository);
            var cars = Dc.Select<Car>(repository);

            Dc.Clear<Person>(repository);

            Dc.Pairs.Add("Key1", "Test value 1");
            Dc.Pairs.Add("Key2", "Test value 2");
            Dc.Pairs.Add("Key3", "Test value 3");
        }
Example #12
0
 public void RemovingFileWithBadParamsThrows()
 {
     var path = SandboxStandardTestRepoGitDir();
     using (var repo = new Repository(path))
     {
         Assert.Throws<ArgumentException>(() => repo.Remove(string.Empty));
         Assert.Throws<ArgumentNullException>(() => repo.Remove((string)null));
         Assert.Throws<ArgumentException>(() => repo.Remove(new string[] { }));
         Assert.Throws<ArgumentNullException>(() => repo.Remove(new string[] { null }));
     }
 }
Example #13
0
        public void RemovingAModifiedFileWhoseChangesHaveBeenPromotedToTheIndexAndWithAdditionalModificationsMadeToItThrows()
        {
            const string filename = "modified_staged_file.txt";

            var path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);

                Assert.Equal(true, File.Exists(fullpath));

                File.AppendAllText(fullpath, "additional content");
                Assert.Equal(FileStatus.Staged | FileStatus.Modified, repo.RetrieveStatus(filename));

                Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename));
                Assert.Throws<RemoveFromIndexException>(() => repo.Remove(filename, false));
            }
        }
Example #14
0
 public bool Remove(T entity)
 {
     return(Repository.Remove(entity));
 }
Example #15
0
 private void Remove(DataAccess.Models.Category category)
 {
     repository.Remove(category);
 }
Example #16
0
        public void CheckoutAddsMissingFilesInWorkingDirectory()
        {
            string repoPath = InitNewRepository();

            using (var repo = new Repository(repoPath))
            {
                PopulateBasicRepository(repo);

                // Remove the file in master branch
                // Verify it exists after checking out otherBranch.
                string fileFullPath = Path.Combine(repo.Info.WorkingDirectory, originalFilePath);
                repo.Remove(fileFullPath);
                repo.Commit("2nd commit", Constants.Signature, Constants.Signature);

                // Checkout other_branch
                Branch otherBranch = repo.Branches[otherBranchName];
                Assert.NotNull(otherBranch);
                otherBranch.Checkout();

                // Verify working directory is updated
                Assert.False(repo.RetrieveStatus().IsDirty);
                Assert.Equal(originalFileContent, File.ReadAllText(fileFullPath));
            }
        }
Example #17
0
        public virtual void Remove(TDto entity)
        {
            var entityMigration = Mapper.Map <TEntity>(entity);

            Repository.Remove(entityMigration);
        }
 public ActionResult Delete(string id)
 {
     subQuanlity.Remove(id);
     return(RedirectToAction("Index"));
 }
Example #19
0
 public override void Remove(int id)
 {
     Repository.Remove(Get(id));
 }
Example #20
0
 public void Execute(RemoveWorkspaceCommand command)
 {
     Repository.Remove(command.Workspace);
 }
Example #21
0
 public void RemoveWorkspace(Workspace workspace)
 {
     Repository.Remove(workspace);
 }
 public void Excluir(int id)
 {
     repoClienteEmpresaContato.Remove(id);
 }
 public void Remove(int observationId)
 {
     _observationRepository.Remove(observationId);
 }
Example #24
0
 public void Delete(AccountBook data)
 {
     //_db.AccountBook.Remove(data);
     _logRepository.Remove(data);
 }
        public void RemoveEntryFromRepositoryTest()
        {
            const string connectionString = @"datasource=localhost;Database=crate;port=3306;username=root;password=root;";
            var dc = new MySqlContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**"
            };

            var repository = new Repository("ConsoleApp");

            dc.Clear<Person>(repository);

            repository.Add(p);
            dc.SubmitChanges(repository);

            repository.Remove(p);
            dc.SubmitChanges(repository);

            var people = dc.Select<Person>(repository);

            Assert.AreEqual(0, people.Count());
        }
 public string Delete(int id)
 {
     repository.Remove(id);
     return(Constants.SUCCESEREMOVE);
 }
Example #27
0
 public void Delete(int notificationId)
 {
     Repository.Remove(notificationId);
     Save();
 }
 private void OnRemoveInspectionMethod(object obj)
 {
     Repository.Remove(SelectedInspectionMethod);
     InspectionMethods.Remove(SelectedInspectionMethod);
 }
Example #29
0
 public void Remove()
 {
     repository.Remove(this);
 }
Example #30
0
 public void RemoveModel(MyModel model)
 {
     Repository <Guid, MyModel> .Remove(model.Id);
 }
Example #31
0
 public virtual ActionResult DeletePage(int id)
 {
     Repository.Remove(Repository.Get <Entry>(id));
     return(RedirectToAction("PageList", "Admin"));
 }
Example #32
0
        //===============================================================
        public static void Exists(Repository<TestClass> repo)
        {
            var item = new TestClass { ID = "1", StringValue = "blah" };
            repo.Insert(item);
            repo.SaveChanges();

            Assert.IsTrue(repo.Exists(item));
            repo.Remove(item);
            repo.SaveChanges();
        }
 public void DeleteAvaliacaoUsuarioById(int AvaliacaoUsuarioId)
 {
     avaliacaoUsuarioRepository.Remove(new { AvaliacaoUsuarioId });
 }
Example #34
0
        //===============================================================
        public static void ChangeTracking(Repository<TestClass> repo)
        {
            var obj = new TestClass("myKey", "myValue");

            repo.Insert(obj);
            repo.SaveChanges();

            var storedObj = repo.Find(obj.ID);
            storedObj.Object.StringValue = "newValue";
            repo.SaveChanges();

            storedObj = repo.Find(obj.ID);
            Assert.AreEqual("newValue", storedObj.Object.StringValue);

            // Test changing list item
            storedObj.Object.List.Add(4);
            repo.SaveChanges();

            storedObj = repo.Find(obj.ID);
            Assert.AreEqual(4, storedObj.Object.List.Count);

            // Test Update function
            repo.Update(new { StringValue = "newValue2" }, storedObj.Object.ID);
            repo.SaveChanges();

            storedObj = repo.Find(obj.ID);
            Assert.AreEqual("newValue2", storedObj.Object.StringValue);

            repo.Remove(storedObj.Object);
            repo.SaveChanges();
        }
Example #35
0
        public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileStatus status)
        {
            for (int i = 0; i < 2; i++)
            {
                var path = SandboxStandardTestRepoGitDir();
                using (var repo = new Repository(path))
                {
                    Assert.Null(repo.Index[relativePath]);
                    Assert.Equal(status, repo.RetrieveStatus(relativePath));

                    Assert.Throws<UnmatchedPathException>(
                        () => repo.Remove(relativePath, i%2 == 0, new ExplicitPathsOptions()));
                }
            }
        }
        public void RemoveEntryFromRepositoryTest()
        {
            const string connectionString = @"Data Source=VLADIMIR5D4B\SQLSERVER;Initial Catalog=Crate;Integrated Security=true;";
            var dc = new SqlServerContext(connectionString, "");

            var p = new Person
            {
                Name = "John Doe",
                Age = 24,
                Email = "*****@*****.**"
            };

            var repository = new Repository("ConsoleApp");

            dc.Clear<Person>(repository);

            repository.Add(p);
            dc.SubmitChanges(repository);

            repository.Remove(p);
            dc.SubmitChanges(repository);

            var people = dc.Select<Person>(repository);

            Assert.AreEqual(0, people.Count());
        }
 public void Remove(TKey key)
 {
     Repository <TKey, TValue> .Remove(key);
 }
Example #38
0
 public int 货品类别_Delete(string 货品类别编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<货品类别>(context);
         var e = r.GetSingle(t => t.编码 == 货品类别编码);
         if (null == e)
             throw new Exception("该类别信息并不存在");
         return r.Remove(e, t => t.编码 == 货品类别编码);
     }
 }
Example #39
0
 public void RevertFile(string path)
 {
     _repository.Remove(path);
 }
Example #40
0
 public void 员工信息_Delete(string 员工信息编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<员工信息>(context);
         var e = r.GetSingle(t => t.编码 == 员工信息编码);
         if (null == e)
             throw new Exception("该员工信息不存在");
         r.Remove(e, t => t.编码 == 员工信息编码);
     }
 }
Example #41
0
 public virtual void Remove(int id)
 {
     Repository.Remove(id);
 }
Example #42
0
        //===============================================================
        public static void InsertAndRemove(Repository<TestClass> testObjects)
        {
            var testObj = new TestClass("myKey", "myValue");

            testObjects.Insert(testObj);
            testObjects.SaveChanges();

            var storedObj = testObjects.Find(testObj.ID);
            Assert.NotNull(storedObj.Object);
            Assert.AreEqual(testObj.ID, storedObj.Object.ID);
            Assert.AreEqual(testObj.ID, storedObj.Object.ID);

            testObjects.Remove(testObj);
            testObjects.SaveChanges();

            storedObj = testObjects.Find(testObj.ID);
            Assert.Null(storedObj);

            testObjects.RemoveAll();
            testObjects.SaveChanges();
        }
Example #43
0
 public bool DeletePowerGroup(string id)
 {
     return(Repository.Remove(id));
 }
Example #44
0
 public bool DeleteUserGroup(string id)
 {
     return(Repository.Remove(id, true));
 }
Example #45
0
        //===============================================================
        public static void TypedRepositoryTest(Repository<TestClass, String> repo)
        {
            var testObj = new TestClass("myKey", "myValue");
            repo.Insert(testObj);
            repo.SaveChanges();

            var newObj = new TestClass { ID = testObj.ID, StringValue = "NEW VALUE" };

            var dbObj = repo.Find(newObj.ID);
            dbObj.Object.StringValue = newObj.StringValue;
            repo.SaveChanges();

            dbObj = repo.Find(newObj.ID);
            Assert.AreEqual(newObj.StringValue, dbObj.Object.StringValue);

            repo.Remove(newObj);
        }
Example #46
0
        public void Execute(UndoCommand command)
        {
            Repository = Container.Resolve <IRepository>();
            var undoGroup = Repository.All <UndoItem>().GroupBy(p => p.Group).LastOrDefault();

            if (undoGroup == null)
            {
                return;
            }
            IsUndoRedo = true;
            try
            {
                foreach (var undoItem in undoGroup)
                {
                    // Create redo item
                    var redoItem = new RedoItem();
                    redoItem.Data         = undoItem.Data;
                    redoItem.Group        = undoItem.Group;
                    redoItem.DataRecordId = undoItem.DataRecordId;
                    redoItem.Name         = undoItem.Name;
                    redoItem.Time         = undoItem.Time;
                    redoItem.Type         = undoItem.Type;
                    redoItem.RecordType   = undoItem.RecordType;
                    redoItem.UndoData     = InvertJsonExtensions.SerializeObject(undoItem).ToString();

                    if (undoItem.Type == UndoType.Inserted)
                    {
                        var record = Repository.GetById <IDataRecord>(undoItem.DataRecordId);
                        redoItem.Data = InvertJsonExtensions.SerializeObject(record).ToString();
                        Repository.Remove(record);
                        redoItem.Type = UndoType.Removed;
                    }
                    else if (undoItem.Type == UndoType.Removed)
                    {
                        var obj =
                            InvertJsonExtensions.DeserializeObject(Type.GetType(undoItem.RecordType),
                                                                   JSON.Parse(undoItem.Data).AsObject) as IDataRecord;
                        Repository.Add(obj);
                        redoItem.Type = UndoType.Inserted;
                        redoItem.Data = InvertJsonExtensions.SerializeObject(obj).ToString();
                    }
                    else
                    {
                        var record = Repository.GetById <IDataRecord>(undoItem.DataRecordId);
                        // We don't want to signal any events on deserialization
                        record.Repository = null;
                        redoItem.Data     = InvertJsonExtensions.SerializeObject(record).ToString();
                        InvertJsonExtensions.DeserializeExistingObject(record, JSON.Parse(undoItem.Data).AsObject);
                        record.Changed    = true;
                        record.Repository = Repository;
                    }
                    Repository.Remove(undoItem);
                    Repository.Add(redoItem);
                }
            }
            catch (Exception ex)
            {
                // If we don't catch the exception IsUndoRedo won't be set back to fals causing cascading issues
            }
            IsUndoRedo = false;
            Repository.Commit();
        }
Example #47
0
        public void CanMergeIntoOrphanedBranch()
        {
            string path = SandboxMergeTestRepo();
            using (var repo = new Repository(path))
            {
                repo.Refs.Add("HEAD", "refs/heads/orphan", true);

                // Remove entries from the working directory
                foreach(var entry in repo.RetrieveStatus())
                {
                    repo.Unstage(entry.FilePath);
                    repo.Remove(entry.FilePath, true);
                }

                // Assert that we have an empty working directory.
                Assert.False(repo.RetrieveStatus().Any());

                MergeResult result = repo.Merge("master", Constants.Signature);

                Assert.Equal(MergeStatus.FastForward, result.Status);
                Assert.Equal(masterBranchInitialId, result.Commit.Id.Sha);
                Assert.False(repo.RetrieveStatus().Any());
            }
        }
 protected override void Delete(Guid id)
 {
     Repository.Remove(id);
 }
Example #49
0
 public int 门店信息_Delete(string 门店编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<门店信息>(context);
         var e = r.GetSingle(t => t.编码 == 门店编码);
         if (null == e)
             throw new Exception("门店信息并不存在");
         if (e.仓库信息List != null && e.仓库信息List.Count > 0)
             throw new Exception("门店所属仓库信息存在");
         if (e.员工信息List != null && e.员工信息List.Count > 0)
             throw new Exception("门店所属员工信息存在");
         if (e.实时库存明细List != null && e.实时库存明细List.Count > 0)
             throw new Exception("门店所属实时库存信息存在");
         if (e.收支费用流水清单List != null && e.收支费用流水清单List.Count > 0)
             throw new Exception("门店所属收支费用明细表存在");
         if (e.日常费用明细表List != null && e.日常费用明细表List.Count > 0)
             throw new Exception("门店所属日常费用明细表存在");
         if (e.菜品销售单List != null && e.菜品销售单List.Count > 0)
             throw new Exception("门店所属菜品销售单存在");
         if (e.费用汇总表List != null && e.费用汇总表List.Count > 0)
             throw new Exception("门店所属费用汇总表存在");
         if (e.采购进货单List != null && e.采购进货单List.Count > 0)
             throw new Exception("门店所属采购进货单存在");
         if (e.餐厅损益表List != null && e.餐厅损益表List.Count > 0)
             throw new Exception("门店所属餐厅损益表存在");
         return r.Remove(e, t => t.编码 == 门店编码);
     }
 }
Example #50
0
 public ActionResult DeleteConfirmed(int id)
 {
     postRepository.Remove(id);
     postRepository.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #51
0
 public int 货品信息_Delete(string 货品信息编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<货品信息>(context);
         var e = r.GetSingle(t => t.编码 == 货品信息编码);
         if (null == e)
             throw new Exception("货品信息并不存在");
         if (e.实时库存List != null && e.实时库存List.Count > 0)
             throw new Exception("实时库存存在此货品信息");
         if (e.货品BOMList != null && e.货品BOMList.Count > 0)
             throw new Exception("货品BOM中存在此货品信息");
         if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0)
             throw new Exception("采购进货单明细中存在此货品信息");
         return r.Remove(e, t => t.编码 == 货品信息编码);
     }
 }
 public void RemoveType()
 {
     Repository.Remove(this);
 }
Example #53
0
 public int 仓库信息_Delete(string 仓库信息编码)
 {
     using (var context = new BDKRContext())
     {
         var r = new Repository<仓库信息>(context);
         var e = r.GetSingle(t => t.编码 == 仓库信息编码);
         if (null == e)
             throw new Exception("仓库信息并不存在");
         if (e.实时库存明细List != null && e.实时库存明细List.Count > 0)
             throw new Exception("实时库存中含有此仓库信息,无法删除!");
         if (e.采购进货单明细List != null && e.采购进货单明细List.Count > 0)
             throw new Exception("采购进货单明细中含有此仓库信息,无法删除!");
         return r.Remove(e);
     }
 }
 public void DeleteComment(Comment comment)
 {
     Repository.Remove <Comment>(comment);
     Repository.SaveChanges();
 }
        public void CanDetectABinaryDeletion()
        {
            using (var repo = new Repository(SandboxStandardTestRepo()))
            {
                const string filename = "binfile.foo";
                var filepath = Path.Combine(repo.Info.WorkingDirectory, filename);

                CreateBinaryFile(filepath);

                repo.Stage(filename);
                var commit = repo.Commit("Add binary file", Constants.Signature, Constants.Signature);

                File.Delete(filepath);

                var patch = repo.Diff.Compare<Patch>(commit.Tree, DiffTargets.WorkingDirectory, new [] {filename});
                Assert.True(patch[filename].IsBinaryComparison);

                repo.Remove(filename);
                var commit2 = repo.Commit("Delete binary file", Constants.Signature, Constants.Signature);

                var patch2 = repo.Diff.Compare<Patch>(commit.Tree, commit2.Tree, new[] { filename });
                Assert.True(patch2[filename].IsBinaryComparison);
            }
        }
Example #56
0
 public void Delete(int id)
 {
     _repository.Remove(id);
 }
        public static void InitFormContainerActions(TileContainer con)
        {
            con.Properties.ItemCheckMode = TileItemCheckMode.Single;
            var deleteAction = new DelegateAction(() => true, async () =>
            {
                var checkedTile = con.Items.FirstOrDefault(x => x.Checked.HasValue && x.Checked.Value) as Tile;
                if (checkedTile == null) return;
                if (checkedTile.Tag == null) return;
                int? formId = TagHelper.GetFormDataId(checkedTile.Tag.ToString());
                if (!formId.HasValue)
                    return;
                var view = (WindowsUIView)con.Manager.View;
                var fly = view.ContentContainers.FindFirst(x => x is Flyout && x.Caption == "Сообщение") as Flyout;
                var formType = ((Page)checkedTile.ActivationTarget).Document.ControlName;
                
                switch (formType)
                {
                    case "FormData1":
                    case "ArchiveFormData1":
                    case "FormData2":
                    case "ArchiveFormData2":
                        {
                            try
                            {
                                using (var repo = new Repository())
                                {
                                    var data = await repo.GetEduFormDataById(formId.Value);
                                    var form = await repo.GetForm(data.form_id);
                                    var res = fly != null ? GuiUtility.ShowFlyoutMessage(view, fly, "Подтверждение", string.Format("Удалить форму \"{0}\"?", form), FlyoutCommand.Yes, FlyoutCommand.No) : MessageBox.Show(string.Format("Удалить форму {0}?", form), "Подтверждение", MessageBoxButtons.OKCancel);
                                    if (res == DialogResult.No)
                                        return;
                                    if (await form.IsBlockedAsync())
                                    {
                                        var mes = fly != null
                                            ? GuiUtility.ShowFlyoutMessage(view, fly, "Информация",
                                                "Удаление формы отключено, так как срок сдачи истек.\n" +
                                                "Чтобы иметь возможность удалить эту форму, обратитесь к региональному оператору")
                                            : MessageBox.Show("Удаление формы отключено, так как срок сдачи истек.\n" +
                                                "Чтобы иметь возможность удалить эту форму, обратитесь к региональному оператору", "Информация", MessageBoxButtons.OKCancel);
                                        return;
                                    }

                                    var file = await repo.GetFile(data.file_id);
                                    var forms = file.edu_form_data;

                                    var tag = TagHelper.GetFormDataTag(TagHelper.TagType.Tile, data);
                                    var tiles = con.Items.Find(t => t.Tag.ToString() == tag).ToArray();

                                    repo.RemoveRange(forms);
                                    repo.Remove(file);
                                    await repo.SaveChangesAsync();

                                    if (con.Items.Count == 1)
                                        con.Items.Clear();
                                    else
                                        con.Items.RemoveRange(tiles);
                                }
                            }
                            catch (Exception ex)
                            {
                                var mess = fly != null ?
                                    GuiUtility.ShowFlyoutMessage(view, fly, "Ошибка удаления", ex.Message) :
                                    MessageBox.Show(ex.Message, "Ошибка удаления", MessageBoxButtons.OK);
                            }
                            break;
                        }
                    case "FormData3":
                    case "ArchiveFormData3":
                    case "FormData4":
                    case "ArchiveFormData4":
                        {
                            try
                            {
                                using (var repo = new Repository())
                                {
                                    var data = await repo.GetMunitFormDataById(formId.Value);
                                    var form = await repo.GetForm(data.form_id);
                                    var res = fly != null ? GuiUtility.ShowFlyoutMessage(view, fly, "Подтверждение", string.Format("Удалить форму \"{0}\"?", form), FlyoutCommand.Yes, FlyoutCommand.No) : MessageBox.Show(string.Format("Удалить форму {0}?", form), "Подтверждение", MessageBoxButtons.OKCancel);
                                    if (res == DialogResult.No)
                                        return;
                                    if (await form.IsBlockedAsync())
                                    {
                                        var mes = fly != null
                                            ? GuiUtility.ShowFlyoutMessage(view, fly, "Информация",
                                                "Удаление формы отключено, так как срок сдачи истек.\n" +
                                                "Чтобы иметь возможность удалить эту форму, обратитесь к региональному оператору")
                                            : MessageBox.Show("Удаление формы отключено, так как срок сдачи истек.\n" +
                                                "Чтобы иметь возможность удалить эту форму, обратитесь к региональному оператору", "Информация", MessageBoxButtons.OKCancel);
                                        return;
                                    }

                                    var file = data.file;
                                    var forms = file.municipality_form_data;

                                    var tag = TagHelper.GetFormDataTag(TagHelper.TagType.Tile, data);
                                    var tiles = con.Items.Find(t => t.Tag.ToString() == tag).ToArray();

                                    repo.RemoveRange(forms);
                                    repo.Remove(file);
                                    await repo.SaveChangesAsync();

                                    if (con.Items.Count == 1)
                                        con.Items.Clear();
                                    else
                                        con.Items.RemoveRange(tiles);
                                }
                            }
                            catch (Exception ex)
                            {
                                var mess = fly != null ?
                                    GuiUtility.ShowFlyoutMessage(view, fly, "Ошибка удаления", ex.Message) :
                                    MessageBox.Show(ex.Message, "Ошибка удаления", MessageBoxButtons.OK);
                            }
                            break;
                        }
                    case "FormData5":
                    case "ArchiveFormData5":
                    case "FormData6":
                    case "ArchiveFormData6":
                        {
                            try
                            {
                                using (var repo = new Repository())
                                {
                                    var data = await repo.GetRegionFormDataById(formId.Value);
                                    var res = fly != null ? GuiUtility.ShowFlyoutMessage(view, fly, "Подтверждение", string.Format("Удалить форму \"{0}\"?", data.form), FlyoutCommand.Yes, FlyoutCommand.No) : MessageBox.Show(string.Format("Удалить форму {0}?", data.form), "Подтверждение", MessageBoxButtons.OKCancel);
                                    if (res == DialogResult.No)
                                        return;
                                    var file = data.file;
                                    var forms = file.region_form_data;

                                    var tag = TagHelper.GetFormDataTag(TagHelper.TagType.Tile, data);
                                    var tiles = con.Items.Find(t => t.Tag.ToString() == tag).ToArray();

                                    repo.RemoveRange(forms);
                                    repo.Remove(file);
                                    await repo.SaveChangesAsync();

                                    if (con.Items.Count == 1)
                                        con.Items.Clear();
                                    else
                                        con.Items.RemoveRange(tiles);
                                }
                            }
                            catch (Exception ex)
                            {
                                var mess = fly != null ?
                                    GuiUtility.ShowFlyoutMessage(view, fly, "Ошибка удаления", ex.Message) :
                                    MessageBox.Show(ex.Message, "Ошибка удаления", MessageBoxButtons.OK);
                            }
                            break;
                        }
                }
            })
            {
                Caption = "Удалить форму",
                Type = ActionType.Context,
                Edge = ActionEdge.Right,
                Behavior = ActionBehavior.HideBarOnClick
            };
            var searchAction = new DelegateAction(() => true, () => (con.Manager.View as WindowsUIView).ShowSearchPanel())
            {
                Caption = "Поиск",
                Type = ActionType.Default,
                Edge = ActionEdge.Left,
                Behavior = ActionBehavior.HideBarOnClick
            };
            con.Actions.Clear();
            con.Actions.Add(deleteAction);
            con.Actions.Add(searchAction);
        }
Example #58
0
        /// <summary>
        /// Graba factura ventas
        /// </summary>
        /// <param name="cliente">Cliente</param>
        /// <param name="detalle">List<BillCore></param>
        /// <param name="numFactura">int</param>
        /// <returns>bool</returns>
        public bool Save(Cliente cliente, List <BillCore> detalle, int numFactura, out long?IdFactura, string miObservacion)
        {
            bool    Result = true;
            Cliente cli    = cliente;
            Factura fac    = null;

            IdFactura = null;

            var repositoryFactura  = new Repository <Factura>();
            var repositoryDetalle  = new Repository <FacturaDetalle>();
            var repositoryKardex   = new Repository <Kardex>();
            var repositoryProducto = new Repository <Producto>();

            //List<Kardex> detalle_ = new List<Kardex>();

            try
            {
                //grabamos la cabecera factura
                int rowFactura = repositoryFactura.Count() + 1;

                fac = repositoryFactura.Create(new Factura
                {
                    IDFactura    = rowFactura,
                    IDCliente    = cli.IDCliente,
                    Numero       = String.Format("{0:00000}", numFactura),
                    Estado       = "A",
                    Fecha        = DateTime.Now,
                    FechaSistema = DateTime.Now,
                    IDTerminal   = Convert.ToInt16(General.Terminal),
                    Observacion  = miObservacion,
                    Tipo         = "V"
                });
                IDFactura = fac.IDFactura;
                IdFactura = IDFactura;
                if (fac == null)
                {
                    throw new Exception(repositoryFactura.Error);
                }

                //grabamos el detalle
                int rowDetalle = repositoryDetalle.Count() + 1;
                int rowKardex  = repositoryKardex.Count() + 1;

                foreach (BillCore de in detalle)
                {
                    //Control si en la siguiente linea de lectura de factura detalle
                    if (de.IdProducto == 0)
                    {
                        break;
                    }
                    if (de.Medida.IdMedidaMetrica == 0)
                    {
                        de.Medida.IdMedidaMetrica = 1;
                    }

                    facturaDetalles.Add(new FacturaDetalle
                    {
                        IDFacturaDetalle = rowDetalle++,
                        IDProducto       = de.IdProducto,
                        Costo            = Convert.ToDecimal(de.Precio),
                        Unidades         = de.Unidades,
                        IDFactura        = fac.IDFactura,
                        FechaSistema     = DateTime.Now,
                        IdMedidaMetrica  = de.Medida.IdMedidaMetrica,
                        IDKardex         = rowKardex,
                        Iva    = Convert.ToBoolean(de.IvaAplica)? Convert.ToInt16(General.Iva):0,
                        Estado = true,
                        Siclo  = "V"
                    });

                    //Obtenemos las compras
                    var listKardexCompras = (from a in repositoryKardex.Search(x => x.IDProducto == de.IdProducto)
                                             where a.Equivalencia > 0 && a.Movimiento != "F"
                                             select a).ToList();

                    foreach (Kardex item in listKardexCompras)
                    {
                        //obtenemos los valores negativo
                        long idFactura = 0;
                        if (item.IDFactura.Contains(Compra))
                        {
                            idFactura = Convert.ToInt16(item.IDFactura.Remove(0, 1));
                        }
                        else
                        {
                            idFactura = Convert.ToInt16(item.IDFactura.Remove(0, 1));
                        }

                        //total del detalle
                        var total = repositoryKardex.Search(x => x.Referencia == idFactura && x.Equivalencia < 0).
                                    Sum(x => x.Equivalencia);

                        //obtenemos las equivalencias de cantidades
                        var equivalencia = 0;
                        var p            = new Repository <Producto>().Find(x => x.IDProducto == de.IdProducto);

                        if (de.Medida.Nivel != null && de.Medida.Nivel == 1)
                        {
                            equivalencia = Convert.ToInt16(p.Equivalencia1);
                        }

                        if (de.Medida.Nivel != null && de.Medida.Nivel == 2)
                        {
                            equivalencia = Convert.ToInt16(p.Equivalencia2);
                        }

                        if (total <= item.Equivalencia)
                        {
                            new CalculoUtilidad().Calcular(de.IdProducto, fac.IDFactura, Convert.ToInt16(de.Unidades),
                                                           Convert.ToDecimal(de.Precio), (de.IvaAplica == true)?General.Iva:0, out kardices,
                                                           de.Medida.IdMedidaMetrica);
                            break;
                        }
                    }

                    //Actualizamos la existencia en el producto
                    var p1 = repositoryProducto.Find(x => x.IDProducto == de.IdProducto);
                    p1.ExistenciaActual = p1.ExistenciaActual - de.Unidades;

                    repositoryProducto.Update(p1);
                }

                repositoryDetalle.AddRange(facturaDetalles);
                if (!repositoryDetalle.Save())
                {
                    throw new Exception(repositoryDetalle.Error);
                }

                //actualizamos las faturas compras las existencias


                var parametros = new Repository <Parametros>();
                var nuFactura  = parametros.Find(x => x.Station == 1);
                nuFactura.NumFactura = nuFactura.NumFactura + 1;
                parametros.Update(nuFactura);

                //Realizar Ajuste
                foreach (var a in detalle)
                {
                    ajustes.Ajustar(a.IdProducto);
                }

                ActualizaDatos(detalle);
            }
            catch (Exception ex)
            {
                //realizamos el rolbak
                repositoryDetalle.RemoveRange(facturaDetalles);
                repositoryKardex.RemoveRange(kardices);
                repositoryFactura.Remove(fac);

                Error  = ex.Message.ToString();
                Result = false;
            }

            return(Result);
        }
 public bool RemoveMark(int markId)
 {
     try
     {
         var repo = new Repository<JournalMarkModel>();
         var mark = repo.GetById(markId);
         repo.Remove(mark);
         return true;
     }
     catch (Exception ex)
     {
         Logger.Error("Error : JournalService.RemoveMark - {0}", ex.Message);
         return false;
     }
 }
Example #60
0
 public void Remove(IDiagramNode diagramNode)
 {
     Repository.Remove(diagramNode);
 }