Example #1
0
        public ObjectRequest EditeCustomer(EditCustomerCommand cmd)
        {
            var customer = _repCustomer.GetEntity(cmd.CustomerId);

            if (customer == null)
            {
                return(new ObjectRequest()
                       .CreateObjectRequest($"Cliente {cmd.Document} não registrado no Sistema ! ", false));
            }

            customer.Edit(cmd.Document, cmd.DateBirthday, cmd.Phone, cmd.Gender);

            _repCustomer.EditEntity(customer);

            if (Commit(customer))
            {
                return(new ObjectRequest().CreateObjectRequest($"Dados do Cliente {cmd.Document} foram alterados com sucesso !", true));
            }

            return(new ObjectRequest().CreateErrorNotification(customer.ListErrors()));
        }
Example #2
0
        public void Teste()
        {
            Random rdm = new Random();

            Users   _user    = new Users("Latino", $"latino{rdm.Next(0, 10000)}@gmail.com", "123456");
            Address _address = new Address("Rua teste", 25, "TesteTeste", "TesteTeste", "TesteTest", "TesteTeste", "78005-210", null);

            Customer _customer = new Customer($"{rdm.Next(100, 999)}56811892", DateTime.Now, "30526425", true, _user);

            _customer.Rel_AdressList.Add(_address);

            _repositoryUsers.AddEntity(_user);
            ((DbContextEF)_context).SaveChanges();


            _repositoryCustomer.AddEntity(_customer);
            ((DbContextEF)_context).SaveChanges();

            var cust = _repositoryCustomer.GetEntity(_customer.ID);

            cust.Edit($"{rdm.Next(100, 999)}78965807", DateTime.Now, "(11)55601730", false);
            _repositoryCustomer.EditEntity(cust);
            ((DbContextEF)_context).SaveChanges();

            var CustMod = _repositoryCustomer.GetEntity(cust.ID);

            var     todos          = _repositoryCustomer.GetAllEntity();
            Address _addressSupply = new Address("Rua testeSupply", 25, "TesteTestetesteSupply", "TesteTestetesteSupply", "TesteTesttesteSupply", "TesteTestetesteSupply", "78005-210", null);
            var     supply         = new Supply("SuplyName", $"75.{rdm.Next(100, 999)}.813/0001-00", "30526425", "AgenteSup", "emailsuply", _addressSupply);

            _repositoryAddress.AddEntity(_addressSupply);
            ((DbContextEF)_context).SaveChanges();

            _repositorySupply.AddEntity(supply);
            ((DbContextEF)_context).SaveChanges();
        }