Пример #1
0
        public ActionResult Create(RepositoryModel model)
        {
            if (ModelState.IsValid)
            {
                bool badName;
                var  repo = RepositoryService.Create(model, Token.UserID, out badName);
                if (repo != null)
                {
                    var success = GitService.CreateRepository(model.Name);
                    if (!success)
                    {
                        RepositoryService.Delete(model.Name);
                        repo = null;
                    }
                }
                if (repo != null)
                {
                    return(RedirectToAction("Detail", "Repository", new { name = repo.Name }));
                }
                if (badName)
                {
                    ModelState.AddModelError("Name", SR.Repository_AlreadyExists);
                }
            }

            return(View(model));
        }
Пример #2
0
        public ActionResult Create(RepositoryModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var repo = RepositoryService.Create(model);
                    if (repo != null)
                    {
                        var success = GitService.CreateRepository(model.Owner, model.Name);
                        if (!success)
                        {
                            RepositoryService.Delete(Token.Username, model.Name);
                            repo = null;
                        }
                    }
                    if (repo != null)
                    {
                        return(RedirectToAction("Tree", "Repository", new { owner = model.Owner, name = repo.Name }));
                    }
                }
                catch (ArgumentException ex)
                {
                    //ModelState.AddModelError(ex.ParamName, SR.Repository_AlreadyExists);
                    ModelState.AddModelError(ex.ParamName, ex.Message);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex);
                }
            }

            return(CreateView(model));
        }
Пример #3
0
        public void Deletar(int id)
        {
            Expression <Func <UnidadeMedida, bool> > filter1 = x => x.Id.Equals(id);
            UnidadeMedida unidademedida = Repository.Filter(filter1).FirstOrDefault();

            Repository.Delete(unidademedida);
        }
Пример #4
0
        public void Deletar(int id)
        {
            Expression <Func <Cardapio, bool> > filter1 = x => x.Id.Equals(id);
            Cardapio Cardapio = Repository.Filter(filter1).FirstOrDefault();

            Repository.Delete(Cardapio);
        }
Пример #5
0
        public void Deletar(int id)
        {
            Expression <Func <Produto, bool> > filter1 = x => x.Id.Equals(id);
            Produto Produto = Repository.Filter(filter1).FirstOrDefault();

            Repository.Delete(Produto);
        }
Пример #6
0
        public void Deletar(int id)
        {
            Expression <Func <Bebida, bool> > filter1 = x => x.Id.Equals(id);
            Bebida Bebida = Repository.Filter(filter1).FirstOrDefault();

            Repository.Delete(Bebida);
        }
        public void RepositoryService_Delete_Throws_On_Null_Repository()
        {
            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<ArgumentNullException>(() => _service.Delete(null));
        }
        public void RepositoryService_Delete_Calls_UnitOfWork_Commit_Method()
        {
            // Create test data
            var newRepository = new Repository
                                        {
                                            Name = "Foo",
                                            Address = "Bar"
                                        };

            //Create Mock
            var mockRepository = new Mock<IRepository<Repository>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Repository>()).Returns(mockRepository.Object);

            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Act
            _service.Delete(newRepository);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
        public void RepositoryService_Delete_Calls_Repsoitory_Delete_Method_With_The_Same_Repository_Object_It_Recieved()
        {
            // Create test data
            var newRepository = new Repository
                                        {
                                            Name = "Foo",
                                            Address = "Bar"
                                        };

            //Create Mock
            var mockRepository = new Mock<IRepository<Repository>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Repository>()).Returns(mockRepository.Object);

            //Arrange
            _service = new RepositoryService(_mockUnitOfWork.Object);

            //Act
            _service.Delete(newRepository);

            //Assert
            mockRepository.Verify(r => r.Delete(newRepository));
        }
Пример #10
0
 public void Delete(TKey id)
 {
     using var uow = UnitOfWorkProvider.Create();
     RepositoryService.Delete(id);
 }