public void Create(Provider provider)
        {
            if (!IsNameAvailable(provider.Name, provider.Id))
            {
                throw new ApplicationException("Un proveedor con el mismo nombre ya ha sido creado");
            }

            Uow.Providers.Add(provider);
            Uow.Commit();
        }
        public void Edit(Provider provider)
        {
            var currentProvider = this.GetById(provider.Id);

            currentProvider.Name = provider.Name;
            currentProvider.Address = provider.Address;
            currentProvider.City = provider.City;
            currentProvider.Referent = provider.Referent;
            currentProvider.Tel1 = provider.Tel1;
            currentProvider.Tel2 = provider.Tel2;
            currentProvider.CellPhone = provider.CellPhone;
            currentProvider.Email = provider.Email;

            Uow.Providers.Edit(currentProvider);
            Uow.Commit();
        }
Example #3
0
        private void FrmAddStock_Load(object sender, EventArgs e)
        {
            using (var depositService = _serviceFactory.Create<IDepositService>())
            {
                var deposits = depositService.GetAll().OrderBy(x => x.Name).ToList();
                ucDepositSelection.Deposits = deposits;
            }

            using (var productService = _serviceFactory.Create<IProductService>())
            {
                var products = productService.GetAll().OrderBy(x => x.Name).ToList();
                ddlProducts.ValueMember = "Id";
                ddlProducts.DisplayMember = "Name";

                var product = new Product();
                product.Id = Guid.Empty;
                product.Name = "Seleccione un producto..";
                products.Insert(0, product);

                ddlProducts.DataSource = products;
            }

            using (var providerService = _serviceFactory.Create<IProviderService>())
            {
                var providers = providerService.GetAll().OrderBy(x => x.Name).ToList();
                ddlProviders.ValueMember = "Id";
                ddlProviders.DisplayMember = "Name";

                var provider = new Provider();
                provider.Id = Guid.Empty;
                provider.Name = "Seleccione un proveedor..";
                providers.Insert(0, provider);

                ddlProviders.DataSource = providers;
            }

            using (var shiftService = _serviceFactory.Create<IShiftService>())
            {
                var shifts = shiftService.GetAll().OrderBy(x => x.Name).ToList();
                ddlShifts.ValueMember = "Id";
                ddlShifts.DisplayMember = "Name";

                var shift = new Shift();
                shift.Id = Guid.Empty;
                shift.Name = "Seleccione un turno..";
                shifts.Insert(0, shift);

                ddlShifts.DataSource = shifts;
            }
        }