Exemplo n.º 1
0
        public async Task GetExistingSuppliersFromDatabaseTest()
        {
            // arrange
            HAVIdatabaseContext dbContext  = CreateDbContext();
            SupplierRepository  repository = new SupplierRepository(dbContext);
            Supplier            supplier1  = new Supplier()
            {
                Id                    = 0,
                ProfileId             = 0,
                CompanyName           = "Name",
                CompanyLocation       = "Location",
                FreightResponsibility = "EXW",
                PalletExchange        = 1,
                Profile               = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };
            Supplier supplier2 = new Supplier()
            {
                Id                    = 0,
                ProfileId             = 0,
                CompanyName           = "Name",
                CompanyLocation       = "Location",
                FreightResponsibility = "EXW",
                PalletExchange        = 1,
                Profile               = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };
            Supplier addedSupplier1 = await repository.AddSupplier(supplier1);

            Supplier addedSupplier2 = await repository.AddSupplier(supplier2);

            // act
            List <Supplier> result = await repository.GetSuppliers();

            // assert
            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(result.Contains(addedSupplier1));
            Assert.IsTrue(result.Contains(addedSupplier2));

            dbContext.Dispose();
        }
Exemplo n.º 2
0
        public async Task DeleteExistingSupplierTest()
        {
            // arrange
            HAVIdatabaseContext dbContext  = CreateDbContext();
            SupplierRepository  repository = new SupplierRepository(dbContext);
            Supplier            supplier   = new Supplier()
            {
                Id                    = 0,
                ProfileId             = 0,
                CompanyName           = "Name",
                CompanyLocation       = "Location",
                FreightResponsibility = "EXW",
                PalletExchange        = 1,
                Profile               = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };
            Supplier addedSupplier = await repository.AddSupplier(supplier);

            // act
            Supplier result = await repository.DeleteSupplierAsync(addedSupplier.Id);

            // assert
            Assert.IsTrue(result == addedSupplier);

            dbContext.Dispose();
        }
Exemplo n.º 3
0
 public long AddSupplier(SupplierObject supplierAccount)
 {
     try
     {
         return(_supplierAccountRepository.AddSupplier(supplierAccount));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Exemplo n.º 4
0
        public async Task <ActionResult <Supplier> > CreateSupplier(Supplier supplier)
        {
            try
            {
                if (supplier == null)
                {
                    return(BadRequest());
                }

                var createdSupplier = await _supplierRepository.AddSupplier(supplier);

                return(createdSupplier);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database."));
            }
        }
Exemplo n.º 5
0
        public ActionResult Create(Supplier supplier)
        {
            //Check Access Rights to Domain
            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update  Model from Form
            try
            {
                UpdateModel(supplier);
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            //Database Update
            try
            {
                supplierRepository.AddSupplier(supplier);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            return(RedirectToAction("List"));
        }
 public ActionResult Add(Supplier supplier)
 {
     try
     {
         if (ModelState.IsValid)
         {
             SupplierRepository subRepo = new SupplierRepository();
             ModelState.Clear();
             int edite = subRepo.AddSupplier(supplier);
             return(RedirectToAction("GetAllSupplierDetails", "Supplier"));
         }
         return(View("GetAllSupplierDetails"));
     }
     catch (Exception ex)
     {
         LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
         return(RedirectToAction("ErrorPage", "Home"));
     }
 }
Exemplo n.º 7
0
        public void AddSupplier()
        {
            Supplier supplier = new Supplier();

            supplier.CompanyName1  = "eng";
            supplier.ContactName1  = "vlada";
            supplier.ContactTitle1 = "zaposleni";
            supplier.Address1      = "beograd";
            supplier.Country1      = "srbija";
            supplier.Fax1          = "123";
            supplier.PostalCode1   = "1100";
            supplier.Phone1        = "064****";
            supplier.HomePage1     = "eng.it";
            supplier.Region1       = "cukarica";
            supplier.City1         = "Beograd";

            SupplierRepository rep = new SupplierRepository();
            int id = rep.AddSupplier(supplier);

            Assert.IsNotNull(id > 0);
        }
Exemplo n.º 8
0
        public async Task GetExistingArticlesForSupplierFromDatabaseTest()
        {
            // arrange
            HAVIdatabaseContext dbContext         = CreateDbContext();
            CountryRepository   countryRepository = new CountryRepository(dbContext);
            Country             country           = new Country()
            {
                Id          = 0,
                ProfileId   = 0,
                CountryName = "Name",
                CountryCode = "Code",
                Profile     = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 0
                }
            };
            PurchaserRepository purchaserRepository = new PurchaserRepository(dbContext);
            Purchaser           purchaser           = new Purchaser()
            {
                Id        = 0,
                ProfileId = 0,
                CountryId = 1,
                Profile   = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };
            await countryRepository.AddCountry(country);

            await purchaserRepository.AddPurchaser(purchaser);

            SupplierRepository supplierRepository = new SupplierRepository(dbContext);
            Supplier           supplier           = new Supplier()
            {
                Id                    = 1,
                ProfileId             = 0,
                CompanyName           = "Name",
                CompanyLocation       = "Location",
                FreightResponsibility = "EXW",
                PalletExchange        = 1,
                Profile               = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };
            ArticleRepository repository = new ArticleRepository(dbContext);
            Article           article1   = new Article()
            {
                Id                                  = 0,
                PurchaserId                         = 1,
                CountryId                           = 1,
                SupplierId                          = 1,
                ArticleInformationId                = 0,
                InternalArticleInformationId        = 0,
                VailedForCustomer                   = "Customer",
                DateCreated                         = DateTime.Now,
                ArticleInformationCompleted         = 0,
                InternalArticalInformationCompleted = 0,
                ArticleState                        = 0,
                ErrorReported                       = 0,
                ErrorField                          = "Field",
                ErrorMessage                        = "Message",
                ErrorOwner                          = "Owner",
                ArticleInformation                  = new ArticleInformation(),
                InternalArticleInformation          = new InternalArticleInformation()
            };
            Article article2 = new Article()
            {
                Id                                  = 0,
                PurchaserId                         = 1,
                CountryId                           = 1,
                SupplierId                          = 1,
                ArticleInformationId                = 0,
                InternalArticleInformationId        = 0,
                VailedForCustomer                   = "Customer",
                DateCreated                         = DateTime.Now,
                ArticleInformationCompleted         = 0,
                InternalArticalInformationCompleted = 0,
                ArticleState                        = 0,
                ErrorReported                       = 0,
                ErrorField                          = "Field",
                ErrorMessage                        = "Message",
                ErrorOwner                          = "Owner",
                ArticleInformation                  = new ArticleInformation(),
                InternalArticleInformation          = new InternalArticleInformation()
            };
            await supplierRepository.AddSupplier(supplier);

            Article addedArticle1 = await repository.AddArticle(article1);

            Article addedArticle2 = await repository.AddArticle(article2);

            // act
            List <Article> result = (List <Article>) await repository.GetArticlesForSupplier(1);

            // assert
            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(result.Contains(addedArticle1));
            Assert.IsTrue(result.Contains(addedArticle2));

            dbContext.Dispose();
        }
Exemplo n.º 9
0
 public IActionResult addSupplier([FromBody] Supplier T)
 {
     return(Ok(supplierRepository.AddSupplier(T)));
 }
Exemplo n.º 10
0
 //Save
 public bool AddSupplier(Supplier supplier)
 {
     return(_supplierRepository.AddSupplier(supplier));
 }
Exemplo n.º 11
0
 public bool AddSupplier(SupplierModel supplierModel)
 {
     return(_supplierRepository.AddSupplier(supplierModel));
 }
Exemplo n.º 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(suppCdTextBox.Text))
            {
                MessageBox.Show("Supplier Code Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppNmTextBox.Text))
            {
                MessageBox.Show("Supplier Name Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppCityTextBox.Text))
            {
                MessageBox.Show("Supplier City Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppTelTextBox.Text))
            {
                MessageBox.Show("Supplier Telephone Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppPinCodeTextBox.Text))
            {
                MessageBox.Show("Supplier Pin Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppCreditLimitTextBox.Text))
            {
                MessageBox.Show("Supplier Credit Amount Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppPaymentTermsTextBox.Text))
            {
                MessageBox.Show("Supplier Payment Terms Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            if (String.IsNullOrEmpty(suppLimitDaysTextBox.Text))
            {
                MessageBox.Show("Supplier Credit Limit Cannot Be Empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }

            SupplierRepository repository = new SupplierRepository();

            if (repository.GetSupplier(suppCdTextBox.Text) != null)
            {
                MessageBox.Show("Supplier Code Provide already exist in the database.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            Supplier supplier = new Supplier();

            supplier.SuppCd           = suppCdTextBox.Text.ToUpper();
            supplier.SuppNm           = suppNmTextBox.Text.ToUpper();
            supplier.SuppBox          = suppBoxTextBox.Text.ToUpper();
            supplier.SuppCity         = suppCityTextBox.Text.ToUpper();
            supplier.SuppLocation     = suppLocationTextBox.Text.ToUpper();
            supplier.SuppTel          = suppTelTextBox.Text.ToUpper();
            supplier.SuppPinCode      = suppPinCodeTextBox.Text.ToUpper();
            supplier.SuppEmail        = suppEmailTextBox.Text;
            supplier.SuppFax          = suppFaxTextBox.Text.ToUpper();
            supplier.SuppCreditLimit  = Convert.ToDecimal(suppCreditLimitTextBox.Text);
            supplier.SuppMobile       = suppMobileTextBox.Text.ToUpper();
            supplier.SuppPaymentTerms = suppPaymentTermsTextBox.Text.ToUpper();
            supplier.SuppLimitDays    = Convert.ToInt32(suppLimitDaysTextBox.Text);
            supplier.SuppVatNo        = suppVatNoTextBox.Text.ToUpper();
            supplier.CreatedBy        = "Test";
            if (repository.AddSupplier(supplier))
            {
                MessageBox.Show("Supplier added Successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                supplier1.SuppCd = suppCdTextBox.Text;
                this.Close();
            }
            else
            {
                MessageBox.Show("Error occurred.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 13
0
        public ActionResult Add(Suppliers supplier)
        {
            repository.AddSupplier(supplier);

            return(RedirectToAction("Index"));
        }
 internal bool AddSupplier(Supplier supplier)
 {
     return(_supplierRepository.AddSupplier(supplier));
 }