Esempio n. 1
0
        public void TestViewLoaded()
        {
            Supplier[] data = new List <Supplier>()
            {
                new Supplier()
                {
                    Id = 1
                },
                new Supplier()
                {
                    Id = 2
                }
            }.ToArray();

            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            mockServiceFactory.Setup(mock => mock.CreateClient <ISupplierService>().GetAllSuppliers()).Returns(data);

            SuppliersViewModel viewModel = new SuppliersViewModel(mockServiceFactory.Object);

            Assert.IsTrue(viewModel.Suppliers == null);

            object loaded = viewModel.ViewLoaded; // fires off the OnViewLoaded protected method

            Assert.IsTrue(viewModel.Suppliers != null && viewModel.Suppliers.Count == data.Length && viewModel.Suppliers[0] == data[0]);
        }
Esempio n. 2
0
        public void TestDeleteSupplierCommand()
        {
            Supplier supplier = new Supplier()
            {
                Id = 1, Name = "Test Name 1"
            };

            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            mockServiceFactory.Setup(mock => mock.CreateClient <ISupplierService>().DeleteSupplier(supplier.Id));

            SuppliersViewModel viewModel = new SuppliersViewModel(mockServiceFactory.Object);

            viewModel.Suppliers = new ObservableCollection <Supplier>()
            {
                supplier
            };

            viewModel.ConfirmDelete += (s, e) => e.Cancel = false;

            Assert.IsTrue(viewModel.Suppliers.Count == 1);

            viewModel.DeleteSupplierCommand.Execute(supplier);

            Assert.IsTrue(viewModel.Suppliers.Count == 0);
        }
Esempio n. 3
0
        public IActionResult Statement(string uuid, string from, string to, SuppliersViewModel model)
        {
            model.Supplier  = Core.GetSupplier(uuid);
            model.Statement = Core.GetSuppliersStatement(model.Supplier, DateTime.Parse(from), DateTime.Parse(to));

            return(View(model));
        }
Esempio n. 4
0
        private void CBManufacturerList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                ComboBox CBTranscationBusiness = (ComboBox)sender;

                if (CBTranscationBusiness != null && CBTranscationBusiness.SelectedItem != null)
                {
                    ManufactureId = ((ManufacturersViewModel)CBTranscationBusiness.SelectedItem).Id;

                    if (BussinessItemsGrid.SelectedItem != null)
                    {
                        SuppliersViewModel model = (SuppliersViewModel)BussinessItemsGrid.SelectedItem;
                        model.ManufacturersName = ((ManufacturersViewModel)CBTranscationBusiness.SelectedItem).Name;
                    }

                    TicketPeriodsByManufacturers = new TicketPeriodsViewModelCollection();
                    TicketPeriodsByManufacturers.QueryByManufacturers(CBMaterialCategoriesId, TranscationItem.Name, ManufactureId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
            }
        }
Esempio n. 5
0
        public SuppliersViewModel GetDeleteSuppliersViewModel(int id)
        {
            Supplier           supplier = this.Context.Suppliers.Find(id);
            SuppliersViewModel model    = Mapper.Map <Supplier, SuppliersViewModel> (supplier);

            return(model);
        }
Esempio n. 6
0
        public static SuppliersViewModel GetDataByID(int id)
        {
            SuppliersViewModel result = new SuppliersViewModel();

            using (POSContext context = new POSContext())
            {
                result = (from po in context.TPurchaseOrder
                          join a in context.TSuppliers on po.SupplierID equals a.ID
                          join p in context.TProvince on a.ProvinceID equals p.ID
                          join r in context.TRegion on a.RegionID equals r.ID
                          join d in context.TDistrict on a.DistrictID equals d.ID
                          select new SuppliersViewModel()
                {
                    ID = a.ID,
                    Address = a.Address,
                    DistrictID = a.DistrictID,
                    DistrictName = d.DistrictName,
                    RegionID = a.RegionID,
                    RegionName = r.RegionName,
                    Email = a.Email,
                    ProvinceID = a.ProvinceID,
                    ProvinceName = p.ProvinceName,
                    Name = a.Name,
                    Phone = a.Phone,
                    PostalCode = a.PostalCode,
                    CreatedBy = a.CreatedBy,
                    CreatedOn = a.CreatedOn,
                    ModifiedBy = a.ModifiedBy,
                    ModifiedOn = a.ModifiedOn
                }).FirstOrDefault();
            }
            return(result);
        }
Esempio n. 7
0
        // GET: api/Suppliers/5
        public IHttpActionResult Get(int id)
        {
            SuppliersViewModel suppliers = null;

            using (NorthwindEntities db = new NorthwindEntities())
            {
                suppliers = db.Suppliers.Where(x => x.SupplierID == id).Select(x => new SuppliersViewModel()
                {
                    SupplierID   = x.SupplierID,
                    CompanyName  = x.CompanyName,
                    ContactName  = x.ContactName,
                    ContactTitle = x.ContactTitle,
                    Address      = x.Address,
                    City         = x.City,
                    PostalCode   = x.PostalCode,
                    Country      = x.Country,
                    Phone        = x.Phone,
                    HomePage     = x.HomePage
                }).FirstOrDefault();
            }
            if (suppliers == null)
            {
                return(NotFound());
            }
            return(Ok(suppliers));
        }
Esempio n. 8
0
 // PUT: api/Suppliers/5
 public IHttpActionResult Put(SuppliersViewModel suppliers)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("No es un modelo "));
     }
     using (var db = new NorthwindEntities())
     {
         var data = db.Suppliers.Where(x => x.SupplierID == suppliers.SupplierID).FirstOrDefault();
         if (data != null)
         {
             data.SupplierID   = suppliers.SupplierID;
             data.CompanyName  = suppliers.CompanyName;
             data.ContactName  = suppliers.ContactName;
             data.ContactTitle = suppliers.ContactTitle;
             data.Address      = suppliers.Address;
             data.City         = suppliers.City;
             data.PostalCode   = suppliers.PostalCode;
             data.Country      = suppliers.Country;
             data.Phone        = suppliers.Phone;
             data.HomePage     = suppliers.HomePage;
         }
         db.SaveChanges();
     }
     return(Ok());
 }
Esempio n. 9
0
        public void TestEditSupplierCommand()
        {
            Supplier supplier = new Supplier()
            {
                Id = 1, Name = "Test Name 1"
            };

            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            SuppliersViewModel viewModel = new SuppliersViewModel(mockServiceFactory.Object);

            viewModel.Suppliers = new ObservableCollection <Supplier>()
            {
                supplier
            };

            Assert.IsTrue(viewModel.Suppliers[0].Name == "Test Name 1");
            Assert.IsTrue(viewModel.CurrentSupplierViewModel == null);

            viewModel.EditSupplierCommand.Execute(supplier);

            Assert.IsTrue(viewModel.CurrentSupplierViewModel != null);

            mockServiceFactory.Setup(mock => mock.CreateClient <ISupplierService>().UpdateSupplier(It.IsAny <Supplier>())).Returns(viewModel.CurrentSupplierViewModel.Supplier);

            viewModel.CurrentSupplierViewModel.Supplier.Name = "Note 2";
            viewModel.CurrentSupplierViewModel.SaveCommand.Execute(null);

            Assert.IsTrue(viewModel.Suppliers[0].Name == "Note 2");
        }
Esempio n. 10
0
        private void CBMaterialCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                //

                CBMaterialCategoriesId = ((MaterialCategoriesViewModel)((ComboBox)sender).SelectedItem).Id;
                if (BussinessItemsGrid.SelectedItem != null)
                {
                    SuppliersViewModel model = (SuppliersViewModel)BussinessItemsGrid.SelectedItem;
                    model.MaterialCategories = ((MaterialCategoriesViewModel)((ComboBox)sender).SelectedItem).Name;
                }
                BussinessItemsByCategories = new ManufacturersBussinessItemsViewModelColletion();
                BussinessItemsByCategories.QueryWithMaterialCategories(CBMaterialCategoriesId);
                //var CBTranscationBusiness = (ComboBox)((DataGridTemplateColumn)BussinessItemsGrid.Columns[1]).CellTemplate.FindName("CBTranscationBusiness", BussinessItemsGrid);
                //if (CBTranscationBusiness != null)
                //{
                //    CBTranscationBusiness.ItemsSource = biselect;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
            }
        }
 public MainWindowViewModel(MedicinesViewModel medicinesViewModel, SuppliersViewModel suppliersViewModel,
                            SuppliesViewModel suppliesViewModel, SalesViewModel salesViewModel)
 {
     MedicinesViewModel = medicinesViewModel;
     SuppliersViewModel = suppliersViewModel;
     SuppliesViewModel  = suppliesViewModel;
     SalesViewModel     = salesViewModel;
 }
Esempio n. 12
0
        public IActionResult Supplier(string uuid, SuppliersViewModel model, AccountsService accounts)
        {
            model.Supplier     = Core.GetSupplier(uuid);
            model.BankAccounts = accounts.GetBankAccountsIEnumerable();
            model.Stations     = Core.GetStationsIEnumerable(true);
            model.Category     = Core.GetExpenseCategoriesIEnumerable();

            return(View(model));
        }
Esempio n. 13
0
        // membuat fung add
        public ActionResult Add()
        {
            ViewBag.ListProvince = new SelectList(ProvinceDAL.GetData(), "ID", "ProvinceName");
            ViewBag.ListRegion   = new SelectList(string.Empty, "", "");
            ViewBag.ListDistrict = new SelectList(string.Empty, "", "");
            SuppliersViewModel model = new SuppliersViewModel();

            return(PartialView("Add", model));
        }
Esempio n. 14
0
        public AppViewModel(SuppliersViewModel suppliersViewModel, WarehousesViewModel warehousesViewModel, EmployeesViewModel employeesViewModel, ProductsViewModel productsViewModel, SuppliesViewModel suppliesViewModel)
        {
            PageViewModels.Add(suppliersViewModel);
            PageViewModels.Add(warehousesViewModel);
            PageViewModels.Add(employeesViewModel);
            PageViewModels.Add(productsViewModel);
            PageViewModels.Add(suppliesViewModel);

            CurrentPageViewModel = PageViewModels[0];
        }
Esempio n. 15
0
        // ini diguunakan untuk edit

        public ActionResult Edit(int Id)
        {
            SuppliersViewModel model = SuppliersDAL.GetDataByID(Id);

            ViewBag.ListProvince = new SelectList(ProvinceDAL.GetData(), "ID", "ProvinceName");
            ViewBag.ListRegion   = new SelectList(string.Empty, "", "");
            ViewBag.ListDistrict = new SelectList(string.Empty, "", "");

            return(PartialView("Edit", model));
        }
        protected override void OnWireViewModelEvents(ViewModelBase viewModel)
        {
            SuppliersViewModel vm = viewModel as SuppliersViewModel;

            if (vm != null)
            {
                vm.ConfirmDelete += OnConfirmDelete;
                vm.ErrorOccured  += OnErrorOccured;
            }
        }
Esempio n. 17
0
        public async static void SuppliersView_Show()
        {
            var viewModel = new SuppliersViewModel();
            await viewModel.InitAsync();

            var f = new Views.Directories.Suppliers.SuppliersView();

            f.DataContext = viewModel;
            f.ShowDialog();
        }
Esempio n. 18
0
        public bool SuppliersAdd([FromBody] SuppliersViewModel model)
        {
            Suppliers db = new Suppliers();

            Mapper.Map(model, db);
            _context.Suppliers.Add(db);
            _context.SaveChanges();
            return(true);


            //
        }
        public ICollection <SuppliersViewModel> GetSuppliers()
        {
            var suppliers = this.Context.Suppliers;
            IList <SuppliersViewModel> models = new List <SuppliersViewModel>();

            foreach (var supplier in suppliers)
            {
                SuppliersViewModel model = Mapper.Map <Supplier, SuppliersViewModel>(supplier);
                models.Add(model);
            }
            return(models);
        }
Esempio n. 20
0
        public SuppliersView()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            var viewModel = new SuppliersViewModel();

            this.DataContext = viewModel;
            if (viewModel.CloseAction == null)
            {
                viewModel.CloseAction = new Action(this.Close);
            }
        }
Esempio n. 21
0
        async void Delete()
        {
            var response = await dialogService.ShowConfirm(
                "Confirm",
                "Are you sure to delete this Supplier ?");

            if (!response)
            {
                return;
            }

            await SuppliersViewModel.GetInstance().Delete(this);
        }
Esempio n. 22
0
 public string GetSupplierDetails(string ID)
 {
     try
     {
         SuppliersViewModel supplierObj = Mapper.Map <Supplier, SuppliersViewModel>(_SupplierBusiness.GetSupplierDetails(ID != null && ID != "" ? Guid.Parse(ID) : Guid.Empty));
         return(JsonConvert.SerializeObject(new { Result = "OK", Records = supplierObj }));
     }
     catch (Exception ex)
     {
         AppConstMessage cm = c.GetMessage(ex.Message);
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
     }
 }
        private SuppliersViewModel GetSuppliersByTypeImporter(bool isImporter)
        {
            string type = isImporter ? "Importer" : "Local";

            IEnumerable <SuppliersListServiceModel> suppliers = this.supplierService.GetAllByType(isImporter);

            SuppliersViewModel model = new SuppliersViewModel
            {
                Type      = type,
                Suppliers = suppliers
            };

            return(model);
        }
Esempio n. 24
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Button             btn  = (Button)sender;
         SuppliersViewModel data = (SuppliersViewModel)btn.DataContext;
         ((SuppliersViewModelCollection)DataContext).Remove(data);
         ((SuppliersViewModelCollection)DataContext).SaveModel();
         ((SuppliersViewModelCollection)DataContext).Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
     }
 }
Esempio n. 25
0
 public string GetSupplierDetailsByIDForMobile(Supplier sup)
 {
     try
     {
         if (sup == null)
         {
             throw new Exception(messages.NoItems);
         }
         SuppliersViewModel supplierObj = Mapper.Map <Supplier, SuppliersViewModel>(_supplierBusiness.GetSupplierDetailsForMobile(sup.ID != null && sup.ID.ToString() != "" ? Guid.Parse(sup.ID.ToString()) : Guid.Empty));
         return(JsonConvert.SerializeObject(new { Result = true, Records = supplierObj }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
Esempio n. 26
0
        public HomepageDetail()
        {
            InitializeComponent();

            //Show India by default
            TiffinMap.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    new Position(
                        23.3355388,
                        78.6230092
                        ),
                    Distance.FromKilometers(1650)
                    )
                );

            BindingContext = viewModel = new SuppliersViewModel();
        }
Esempio n. 27
0
        public ICollection <SuppliersViewModel> GetSuppliers()
        {
            var suppliers = this.Context.Suppliers;
            IList <SuppliersViewModel> models = new List <SuppliersViewModel>();

            foreach (var supplier in suppliers)
            {
                //SuppliersViewModel model = new SuppliersViewModel()
                //{
                //    Id = supplier.Id,
                //    Name = supplier.Name
                //};
                SuppliersViewModel model = Mapper.Map <Supplier, SuppliersViewModel>(supplier);
                models.Add(model);
            }
            return(models);
        }
Esempio n. 28
0
        public IActionResult GetSuppliers(string supplierType)
        {
            var supplierTypeEnum = SupplierType.Local;

            if (supplierType != null)
            {
                Enum.TryParse(supplierType, true, out supplierTypeEnum);
            }

            var supplierViewModel = new SuppliersViewModel
            {
                SupplierType = supplierTypeEnum,
                Suppliers    = this.supplierService.GetSuppliersByType(supplierTypeEnum)
            };

            return(View(supplierViewModel));
        }
Esempio n. 29
0
        public void TestCurrentSupplierSetting()
        {
            Supplier supplier = new Supplier()
            {
                Id = 1
            };

            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            SuppliersViewModel viewModel = new SuppliersViewModel(mockServiceFactory.Object);

            Assert.IsTrue(viewModel.CurrentSupplierViewModel == null);

            viewModel.EditSupplierCommand.Execute(supplier);

            Assert.IsTrue(viewModel.CurrentSupplierViewModel != null && viewModel.CurrentSupplierViewModel.Supplier.Id == supplier.Id);
        }
Esempio n. 30
0
        public ActionResult Delete(SuppliersViewModel model)
        {
            using (POSContext context = new POSContext())
            {
                Suppliers item = context.TSuppliers.Where(x => x.ID == model.ID).FirstOrDefault();
                context.TSuppliers.Remove(item);

                try
                {
                    context.SaveChanges();
                    return(Json(new { success = true }));
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }