Beispiel #1
0
        //Add Data
        public bool Add(Supplier objSupplier)
        {
            var isAdded = false;

            isAdded = _sapplierRepository.Add(objSupplier);
            if (isAdded)
            {
                return(true);
            }

            return(isAdded);
        }
Beispiel #2
0
        public void ConstructorSetsCorrectEfenkaContext() //done by checking if getbyid works
        {
            EfenkaContextTestFactory.Create();

            _sut = new SupplierRepository(EfenkaContextTestFactory.EfenkaContext);

            var supplier = new Supplier();

            _sut.Add(supplier);

            var supplierFromDatabase = _sut.GetById(supplier.Id);

            Assert.That(supplierFromDatabase, Is.EqualTo(supplier));
        }
Beispiel #3
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtName.Text != "")
                {
                    Suppliers _Suppliers = new Suppliers();
                    _Suppliers.Name    = txtName.Text;
                    _Suppliers.Email   = txtEmail.Text;
                    _Suppliers.Contact = txtContact.Text;
                    _Suppliers.Address = txtAddress.Text;

                    decimal AlreadyExistSupplier = _SupplierRepository.AlreadyExistSupplier(_Suppliers);
                    if (AlreadyExistSupplier >= 1)
                    {
                        lblmsg.Text      = "This Supplier Already Here!!....";
                        lblmsg.ForeColor = Color.Red;
                        txtName.Focus();
                    }
                    else
                    {
                        int Savesuccess = _SupplierRepository.Add(_Suppliers);
                        if (Savesuccess > 0)
                        {
                            lblmsg.Text      = "This Supplier Save Successefully!!....";
                            lblmsg.ForeColor = Color.Green;

                            Response.Redirect(Request.Url.AbsoluteUri);
                        }
                        else
                        {
                            lblmsg.Text      = "This Supplier Saving Failed!!....";
                            lblmsg.ForeColor = Color.Red;
                        }
                    }
                }
                else
                {
                    txtName.Focus();
                    lblmsg.Text      = "Please Type Supplier Name";
                    lblmsg.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text      = ex.Message;
                lblmsg.ForeColor = Color.Red;
            }
        }
Beispiel #4
0
        public ActionResult Add(SupplierInfo model)
        {
            Employee em = (Employee)Session[CommonConstants.USER_SESSION];

            model.CreatedBy    = em.id;
            model.ModifyBy     = em.id;
            model.SupplierCode = model.SupplierCode.ToUpper(); //Chuyển trường mã thành dạng chữ in hoa
            var result = _supRepo.Add(model);

            if (result == 1)
            {
                return(Json(new { status = 1, message = "Thêm thành công" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { status = 0, message = "Thêm thất bại" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        /// <summary>
        /// Create suppliers
        /// </summary>
        /// <param name="request">request to create supplier</param>
        /// <returns>returns response of the operation</returns>
        public CreateSupplierResponse CreateSupplier(CreateSupplierRequest request)
        {
            //Map request to entity
            var supplierEntities = request.Suppliers.Select(staff => new SupplierEntity
            {
                ID = staff.ID,
                Latitude = staff.Latitude,
                Longitude = staff.Longitude,
                SatisfactionIndex = staff.SatisfactionIndex
            });

            //Add supplier on db
            _supplierRepository.Add(supplierEntities);

            return new CreateSupplierResponse();
        }
Beispiel #6
0
        public new bool Add(Supplier supplier)
        {
            var su = new Supplier();

            su.SupplierCode = supplier.SupplierCode;
            su.UniformCode  = supplier.UniformCode;
            su.CustomCode   = supplier.CustomCode;
            su.SupplierName = supplier.SupplierName;
            su.ProvinceName = supplier.ProvinceName;
            su.IsActive     = supplier.IsActive;
            su.UpdateTime   = DateTime.Now;

            SupplierRepository.Add(su);
            SupplierRepository.SaveChanges();
            return(true);
        }
Beispiel #7
0
        public void Add_SupplierRepository_SupplierAdded()
        {
            // Arrange
            SupplierEntity    supplierEntity    = new SupplierEntity(1, "Pirma", 1, true, true, 21);
            SupplierEntity    supplierEntity2   = new SupplierEntity(2, "Antra", 1, true, false, 21);
            SupplierEntity    supplierEntity3   = new SupplierEntity(3, "Trecia", 2, false, true, 18);
            InvoiceController invoiceController = new InvoiceController(_clientRepository, _supplierRepository);

            // Act
            _supplierRepository.Add(supplierEntity);
            _supplierRepository.Add(supplierEntity2);
            _supplierRepository.Add(supplierEntity3);

            // Assert

            Assert.AreEqual("Pirma", _supplierRepository.GetBy(1).Name);
            Assert.AreEqual(false, _supplierRepository.GetBy(2).IsVATPayer);
            Assert.AreEqual("Trecia", _supplierRepository.GetBy(3).Name);
            Assert.AreEqual(3, _supplierRepository.GetBy(3).Id);
            Assert.AreEqual(3, _supplierRepository.GetCount());
        }
Beispiel #8
0
        public void GivenTheFollowingSuppliers(Table givenSuppliers)
        {
            var repository = new SupplierRepository();

            foreach (var row in givenSuppliers.Rows)
            {
                Supplier s = new Supplier {
                    Name = row["Supplier Name"], Id = Convert.ToInt32(row["Supplier Id"]), Address = row["Supplier Address"]
                };
                repository.Add(s);
            }
            int actualCount = repository.GetSuppliers().Count();

            var givenNames    = givenSuppliers.Rows.Select(r => r["Supplier Name"]);
            var expectedNames = repository.GetSuppliers().Select(s => s.Name);

            Assert.AreEqual(givenSuppliers.RowCount, actualCount, "Supplier lists don't contain expected number of suppliers.");
            Assert.IsTrue(givenNames.Except(expectedNames).Count() == 0, "Supplier lists don't contain expected suppliers.");
        }
Beispiel #9
0
        private async void OnSave()
        {
            // Create Factory
            RepositoryFactory <SupplierRepository, Supplier> factory =
                new RepositoryFactory <SupplierRepository, Supplier>();

            // Create Repository
            SupplierRepository supplierRepository = factory.Create();

            if (!EditMode)
            {
                supplierRepository.Update();
            }
            else
            {
                supplierRepository.Add(SelectedSupplier);
            }

            Done();
        }
Beispiel #10
0
        private void ButtonSaveNewObject_Click(object sender, RoutedEventArgs e)
        {
            {
                repo = new SupplierRepository();

                Supplier supplier = new Supplier()
                {
                    CompanyName = textBoxCompanyName.Text,
                    ContactName = textBoxContactName.Text,
                    Address     = textBoxAddress.Text,
                    City        = textBoxCity.Text,
                    Region      = textBoxRegion.Text,
                    PostalCode  = textBoxPostalCode.Text,
                    Country     = textBoxCountry.Text,
                    Phone       = textBoxPhone.Text,
                    Fax         = textBoxFax.Text,
                    HomePage    = textBoxHomePage.Text,
                };
                repo.Add(supplier);
                supplierViewModel.Suppliers.Add(supplier);
                StopAddition();
            }
        }
 public bool Add(Supplier supplier)
 {
     return(_supplierRepository.Add(supplier));
 }
Beispiel #12
0
 public bool Add(SupplierModel supplierModel)
 {
     return(_supplierRepository.Add(supplierModel));
 }
 public ActionResult AddSupplier(Supplier supplier)
 {
     sRep.Add(supplier);
     return(RedirectToAction("SupplierList"));
 }
Beispiel #14
0
 public int AddSupplier(Supplier supplier)
 {
     return(supplierRepository.Add(supplier));
 }