public async Task <ActionResult> SupplierRegis([Bind(Include = "suppliersave_SupplierID,suppliersave_SupplierName,suppliersave_Notes")] RegisterSupplier model)
        {
            using (var context = new IdentityDb())
            {
                if (ModelState.IsValid)
                {
                    var roleStore   = new RoleStore <IdentityRole>(context);
                    var roleManager = new RoleManager <IdentityRole>(roleStore);

                    var user = new ApplicationUser {
                        UserName = model.registsupplier.Username, SupplierName = model.registsupplier.SupplierName
                    };
                    var result = await UserManager.CreateAsync(user, model.registsupplier.Password);

                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                        await UserManager.FindAsync(model.registsupplier.Username, model.registsupplier.Password);

                        await this.UserManager.AddToRoleAsync(user.Id, "supplier");
                    }

                    db.Suppliers.Add(model.suppliersave);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View());
        }
        public void RegisterSupplierTest()
        {
            Supplier supplier3 = new Supplier
            {
                SupplierId = 3,
                Name       = "Luis",
                LastName   = "Perez",
                Email      = "*****@*****.**",
                Phone      = "9456789",
                Age        = 45,
                Gender     = "Masculino",
                UsuarioId  = 1,
                LocationId = 1,
                Country    = "Peru",
                State      = "Lima",
                City       = "Lima",
                Address    = "Lima av. 25",
                Contraseña = "456789"
            };


            mockRepository.Setup(x => x.RegisterSupplier(supplier3))
            .Returns(true);

            var handler = new RegisterSupplierHandler(mockRepository.Object);

            RegisterSupplier ru = new RegisterSupplier(supplier3);

            var res = handler.Handle(ru, ct);

            Assert.IsTrue(res.Result);
        }
Exemple #3
0
        private void bunifuFlatButton3_Click(object sender, EventArgs e)
        {
            RegisterSupplier item = new RegisterSupplier(user);

            panel1.Controls.Clear();
            //item.Top = 10;
            //item.Left = 10;
            panel1.Controls.Add(item);
        }
Exemple #4
0
        public async Task RegisterSupplier_Success()
        {
            //arrange
            var command = new RegisterSupplier()
            {
                Name = "Pvc Foil supplier",
                SuppliableArticleIds = new List <Guid> {
                    Material2Foil.Id
                },
                PrimaryContactFirstName   = "John",
                PrimaryContactLastName    = "Smith",
                PrimaryContactPhone       = "381111111111",
                PrimaryContactEmail       = "*****@*****.**",
                ShippingAddressLine1      = "2 Paper st.",
                ShippingAddressLine2      = "2 Apt.",
                ShippingAddressCity       = "Kyiv",
                ShippingAddressProvince   = "Kyiv",
                ShippingAddressCountry    = "Ukraine",
                ShippingAddressPostalCode = "37008",
                InitiatorId = GlobalAdmin.Id
            };
            var handler = new RegisterSupplierHandler(EntityRepository, EventTransmitter);

            //act
            await handler.HandleAsync(command);

            //assert
            var entities = GetRecordedEntities <Supplier>(EntityRepository, nameof(EntityRepository.AddAsync));

            Assert.That(entities.Count, Is.EqualTo(1));
            Assert.That(entities[0].Name, Is.EqualTo(command.Name));
            Assert.That(entities[0].SuppliableArticles.Count, Is.EqualTo(1));
            Assert.That(entities[0].SuppliableArticles.Single(), Is.EqualTo(Material2Foil));
            Assert.That(entities[0].PrimaryContact.FirstName, Is.EqualTo(command.PrimaryContactFirstName));
            Assert.That(entities[0].PrimaryContact.LastName, Is.EqualTo(command.PrimaryContactLastName));
            Assert.That(entities[0].PrimaryContact.PhoneNumber, Is.EqualTo(command.PrimaryContactPhone));
            Assert.That(entities[0].PrimaryContact.Email, Is.EqualTo(command.PrimaryContactEmail));
            Assert.That(entities[0].ShippingAddress.AddressLine1, Is.EqualTo(command.ShippingAddressLine1));
            Assert.That(entities[0].ShippingAddress.AddressLine2, Is.EqualTo(command.ShippingAddressLine2));
            Assert.That(entities[0].ShippingAddress.City, Is.EqualTo(command.ShippingAddressCity));
            Assert.That(entities[0].ShippingAddress.Province, Is.EqualTo(command.ShippingAddressProvince));
            Assert.That(entities[0].ShippingAddress.Country, Is.EqualTo(command.ShippingAddressCountry));
            Assert.That(entities[0].ShippingAddress.PostalCode, Is.EqualTo(command.ShippingAddressPostalCode));

            var events = GetRecordedEvents <DomainEvent <Supplier> >();

            Assert.That(events.Count, Is.EqualTo(1));
            Assert.That(events[0].Trigger, Is.EqualTo(Trigger.Added));
            Assert.That(events[0].Entity, Is.EqualTo(entities[0]));
            Assert.That(events[0].RaisedBy, Is.EqualTo(command.InitiatorId));
        }