public CustomersView() { vm = ContainerHelper.Container.Resolve <CustomersViewModel>(); DataContext = vm; InitializeComponent(); }
public JsonResult Add(CustomersViewModel emp) { return(Json(objcustomer.SaveCustomers(emp), JsonRequestBehavior.AllowGet)); }
public EmergencyAgreementView() { InitializeComponent(); AssignSelectAllForTextBoxes(); LoadingIndicatorPanel.Visibility = Visibility.Visible; gridResizableEmergencyAgreements.IsEnabled = false; Task.Factory.StartNew(() => { var customersVM = new CustomersViewModel(); customersVM.RefreshOnlyCustomers(); var result = Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { customersView = new CustomersView(); customersView.CustomersVM = customersVM; frameCustomers.Content = customersView; locationsView = new LocationsView(); frameLocations.Content = locationsView; var machineInformationsView = new MachineInformationsView(); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.GoogleDriveFolderName)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.ContactPerson)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Description)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Payload)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Entrances)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.HoldingPositions)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.HoldingPositions)); frameMachineInformations.Content = machineInformationsView; masterDataInfo = new MasterDataInfoView(Helper.Helper.TTypeMangement.EmergencyAgreement); masterDataInfo.cbMachineInformations.SelectionChanged += CbMachineInformations_SelectionChanged; masterDataInfo.RefreshCustomers(); frameMasterDataInfo.Content = masterDataInfo; customersView.dgCustomers.SelectionChanged += DgCustomers_SelectionChanged; locationsView.dgLocations.SelectionChanged += DgLocations_SelectionChanged; machineInformationsView.dgMachineInformations.SelectionChanged += DgMachineInformations_SelectionChanged; NotVisibleColumns.Add(nameof(EmergencyAgreement.GoogleCalendarEventId)); dgEmergencyAgreements.Tag = NotVisibleColumns; dgEmergencyAgreements.SelectionChanged += DgEmergencyAgreements_SelectionChanged; dgEmergencyAgreements.SelectedIndex = 0; EmergencyAgreementVM.LoadComboboxes(); AssigneValuesToControl(); cbNoticeOfPeriodMonth.ItemsSource = GetMonths(); cbNoticeOfPeriodMonth.SelectedIndex = 2; txtNoticeOfPeriod.Text = "Monate"; EnableContoles(false); })); }).ContinueWith((task) => { LoadingIndicatorPanel.Visibility = Visibility.Collapsed; gridResizableEmergencyAgreements.IsEnabled = true; }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void LoadData() { viewModel = CustomersViewModel.GetDefault(); CustomersList.ItemsSource = viewModel.GetAllItems(); }
public MainWindow() { InitializeComponent(); viewModel = new CustomersViewModel(); this.DataContext = viewModel; }
private void InitModules() { ViewInjectionManager.Default.Inject( Regions.Navigation, ModuleType.Customers, () => NavigationItemViewModel.Create("Customers", new BitmapImage(new Uri(@"../Images/Customers.png", UriKind.RelativeOrAbsolute)), ModuleType.Customers), typeof(NavigationItemView) ); ViewInjectionManager.Default.Inject( Regions.Navigation, ModuleType.Sales, () => NavigationItemViewModel.Create("Sales", new BitmapImage(new Uri(@"../Images/Sales.png", UriKind.RelativeOrAbsolute)), ModuleType.Sales), typeof(NavigationItemView) ); ViewInjectionManager.Default.Inject( Regions.Navigation, ModuleType.Products, () => NavigationItemViewModel.Create("Products", new BitmapImage(new Uri(@"../Images/Products.png", UriKind.RelativeOrAbsolute)), ModuleType.Products), typeof(NavigationItemView) ); ViewInjectionManager.Default.Inject(Regions.Main, ModuleType.Customers, () => CustomersViewModel.Create(), typeof(CustomersView)); ViewInjectionManager.Default.Inject(Regions.Main, ModuleType.Sales, () => SalesViewModel.Create(), typeof(SalesView)); ViewInjectionManager.Default.Inject(Regions.Main, ModuleType.Products, () => ProductsViewModel.Create(), typeof(ProductsView)); ViewInjectionManager.Default.Navigate(Regions.Navigation, ModuleType.Customers); ViewInjectionManager.Default.Navigate(Regions.Main, ModuleType.Customers); }
public ActionResult EditAddressSave(Address address) { CustomersViewModel model = new CustomersViewModel(); return(View("Index", model)); }
public CustomersControl() { InitializeComponent(); DataContext = new CustomersViewModel(); }
public async Task <IHttpActionResult> GetCustomers(HttpRequestMessage request, [FromBody] CustomersViewModel customersViewModel) { IHttpActionResult response = null; try { CustomersViewModel result = new CustomersViewModel(); var currentLoggedInUser = UserHelper.GetUserInfo(this); int currentPageNumber = customersViewModel.CurrentPageNumber; int pageSize = customersViewModel.PageSize; string sortExpression = customersViewModel.SortExpression; string sortDirection = customersViewModel.SortDirection; int totalRows; List <Organization> customers = _customerDataService.GetCustomers(currentLoggedInUser.OrganizationID, customersViewModel.AccountNumber, customersViewModel.AccountName, customersViewModel.AdminUser, customersViewModel.UserName, customersViewModel.StatusName, customersViewModel.LastLoginDate, currentPageNumber, pageSize, sortExpression, sortDirection, out totalRows); // customerViewModelList = new CustomerViewModelList(); //foreach (Customer customer in customers) //{ // CustomerViewModel customerViewModel = customer; // customerViewModelList.Add(customerViewModel); //} var customerViewModelList = customers.Select(user => (CustomerViewModel)user); result.Customers = customerViewModelList.ToList(); result.TotalRows = totalRows; response = ResponseMessage(Request.CreateResponse <CustomersViewModel>(HttpStatusCode.OK, result)); } catch (Exception ex) { string message = UserHelper.ErrorHandler(ex); response = BadRequest(message); } return(response); }
public IActionResult Create(int?id, int?userId) { int loggedInUserId; Claim user = User.FindFirst(c => c.Type == ClaimTypes.SerialNumber); string userValue = user.Value; Int32.TryParse(userValue, out loggedInUserId); if ((userId != loggedInUserId) && (!User.IsInRole("Registrator"))) { return(View("Forbidden")); } if (id != null || userId != null) { if (userId != null && (_context.Customer.Any(c => c.CustomerExistedFlag && c.UsersId == userId)) && (!User.IsInRole("Registrator"))) { id = _context.Customer.FirstOrDefault(c => c.CustomerExistedFlag && c.UsersId == userId).CustomerId; } else { if (!User.IsInRole("Registrator")) { return(NotFound()); } } var customer = _context.Customer.Include(c => c.Users).ThenInclude(u => u.UserRoles).Where(s => s.CustomerExistedFlag).SingleOrDefault(m => m.CustomerId == id); CustomersViewModel instance = new CustomersViewModel(); instance.Customers = customer; //instance.ClinicalDepartment = _context.ClinicalDepartment.Where(c => c.ClinicalDepartmentExistedFlag).ToList(); // В случае вызова формы создания профиля модальным окном возвращать частичное представление. if (Request.Headers["X-Requested-With"] == "XMLHttpRequest") { return(PartialView(instance)); } // В случае вызова формы создания профиля отдельным окном (отдельной вкладкой) возвращать полное представление. else { return(View(instance)); } } else { if (!User.IsInRole("Registrator")) { return(View("Forbidden")); } // В случае вызова формы создания профиля модальным окном возвращать частичное представление. if (Request.Headers["X-Requested-With"] == "XMLHttpRequest") { CustomersViewModel returnView = new CustomersViewModel(); returnView.Customers = new Customer(); returnView.Customers.Users = new Users(); returnView.Customers.Users.UserRoles = new Roles(); return(PartialView(returnView)); } // В случае вызова формы создания профиля отдельным окном (отдельной вкладкой) возвращать полное представление. else { CustomersViewModel returnView = new CustomersViewModel(); returnView.Customers = new Customer(); returnView.Customers.Users = new Users(); returnView.Customers.Users.UserRoles = new Roles(); return(View(returnView)); } } }
public IActionResult Create(CustomersViewModel customersViewModel, int?id, int?userId) { int loggedInUserId; Claim userCheck = User.FindFirst(c => c.Type == ClaimTypes.SerialNumber); string userValue = userCheck.Value; Int32.TryParse(userValue, out loggedInUserId); if ((userId != loggedInUserId) && (!User.IsInRole("Registrator"))) { return(View("Forbidden")); } // Если в контроллер пришёл id, значит требуется правка, а не создание. if (id != null || userId != null) { // Если id не соответствуют, то, значит, такого нет, и возвращется HTTP-ответ с кодом 404 ("Не найдено"). if (id != customersViewModel.Customers.CustomerId) { return(NotFound()); } if (userId != null && (_context.Customer.Any(c => c.CustomerExistedFlag && c.UsersId == userId)) && (!User.IsInRole("Registrator"))) { id = _context.Customer.FirstOrDefault(c => c.CustomerExistedFlag && c.UsersId == userId).CustomerId; } else { if (!User.IsInRole("Registrator")) { return(NotFound()); } } // Проверка модели на правильность. if (ModelState.IsValid) { try { // Отметка о том, что профиль активный (не удалённый). customersViewModel.Customers.CustomerExistedFlag = true; customersViewModel.Customers.Users.UsersExistedFlag = true; customersViewModel.Customers.Users.RolesId = _context.Roles.FirstOrDefault(r => r.RolesName == "SimpleUser").RolesId; Customer customer = customersViewModel.Customers; Users user = customer.Users; user.UsersId = _context.Users.AsNoTracking().FirstOrDefault(u => u.UsersId == customer.UsersId).UsersId; // Занесение сделанных правок в базу данных. _context.Update(user); _context.Update(customer); // Сохранение изменений в базе данных. _context.SaveChanges(); } // Проверка на конкурирующие запросы к базе данных. catch (DbUpdateConcurrencyException) { // Если такого профиля нет, то возвращется HTTP-ответ с кодом 404 ("Не найдено"). if ((!InstanceExists(customersViewModel.Customers.CustomerId)) || (!customersViewModel.Customers.CustomerExistedFlag)) { return(NotFound()); } else { throw; } } return(new EmptyResult()); } return(PartialView(customersViewModel)); } else { // Проверка модели на правильность. if (ModelState.IsValid) { if (_context.Customer.Any(d => d.Users.UsersPhoneNumber == customersViewModel.Customers.Users.UsersPhoneNumber || d.Users.UsersEmail == customersViewModel.Customers.Users.UsersEmail && d.Users.UsersExistedFlag)) { return(BadRequest()); } // Отметка о том, что теперь профиль существует и активен. customersViewModel.Customers.CustomerExistedFlag = true; customersViewModel.Customers.Users.UsersExistedFlag = true; customersViewModel.Customers.Users.RolesId = _context.Roles.FirstOrDefault(r => r.RolesName == "SimpleUser").RolesId; Customer customer = customersViewModel.Customers; Users user = customersViewModel.Customers.Users; // Занесение сделанных правок в базу данных. _context.Add(customer); _context.Add(user); _context.SaveChanges(); return(new EmptyResult()); } return(PartialView(customersViewModel)); } }
public ReportView() { InitializeComponent(); var customersVM = new CustomersViewModel(); customersVM.RefreshOnlyCustomers(); customersView = new CustomersView(); customersView.CustomersVM = customersVM; frameCustomers.Content = customersView; locationsView = new LocationsView(); frameLocations.Content = locationsView; var machineInformationsView = new MachineInformationsView(); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.GoogleDriveFolderName)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.ContactPerson)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Description)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Payload)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.Entrances)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.HoldingPositions)); machineInformationsView.NotVisibleColumns.Add(nameof(MachineInformation.HoldingPositions)); frameMachineInformations.Content = machineInformationsView; masterDataInfo = new MasterDataInfoView(Helper.Helper.TTypeMangement.MaintenanceAgreement); masterDataInfo.cbMachineInformations.SelectionChanged += CbMachineInformations_SelectionChanged; masterDataInfo.RefreshCustomers(); frameMasterDataInfo.Content = masterDataInfo; customersView.dgCustomers.SelectionChanged += DgCustomers_SelectionChanged; locationsView.dgLocations.SelectionChanged += DgLocations_SelectionChanged; machineInformationsView.dgMachineInformations.SelectionChanged += DgMachineInformations_SelectionChanged; BindingControl(dgReports, () => ReportVM.Records); BindingTextBlock(txtOfferPrice, () => ReportVM.OfferPriceSum, null, "c"); BindingTextBlock(txtBillingAmountCorrect, () => ReportVM.BillingAmountCorrecteSum, null, "c"); BindingTextBlock(txtSavingCost, () => ReportVM.SavingCostSum, null, "c"); var binding = new Binding(GetPropertyPath(() => ReportVM.SavingCostSum)) { Source = this, }; binding.Mode = BindingMode.TwoWay; binding.Converter = new ValueToForegroundColorConverter(); txtSavingCost.SetBinding(TextBlock.ForegroundProperty, binding); BindingComboBoxBindingModeOneWay(cbYears, () => ReportVM.Years); BindingComboBoxSelectedValue(cbYears, () => ReportVM.YearSelected); var rbbinding = new Binding(GetPropertyPath(() => ReportVM.YearChecked)) { Source = this, }; rbbinding.Mode = BindingMode.TwoWay; rbYear.SetBinding(RadioButton.IsCheckedProperty, rbbinding); BindingDatePicker(datePickerDurationStart, () => ReportVM.ReportStart); BindingDatePicker(datePickerDurationEnd, () => ReportVM.ReportEnd); }
public ActionResult Index() { CustomersViewModel viewModel = this.customerMVCService.GetCustomers(); return(View(viewModel)); }
public MachineInformationView() { InitializeComponent(); AssignSelectAllForTextBoxes(); //TODO select only Customer //TODO Datetime Validation and format of filed //Task.Factory.StartNew(() => //{ // var customersVM = new CustomersViewModel(); // customersVM.RefreshOnlyCustomers(); // Application.Current.Dispatcher.BeginInvoke( // DispatcherPriority.Background, // new Action(() => // { // customersView = new CustomersView(); // customersView.CustomersVM = customersVM; // frameCustomers.Content = customersView; // var locationsView = new LocationsView(); // frameLocations.Content = locationsView; // customersView.expanderCustomers.Collapsed += ExpanderCustomers_Collapsed; // customersView.dgCustomers.SelectionChanged += DgCustomers_SelectionChanged; // locationsView.expanderLocations.Collapsed += ExpanderLocations_Collapsed; // locationsView.dgLocations.SelectionChanged += DgLocations_SelectionChanged; // })); //}); LoadingIndicatorPanel.Visibility = Visibility.Visible; gridResizableMachineInformation.IsEnabled = false; Task.Factory.StartNew(() => { var customersVM = new CustomersViewModel(); customersVM.RefreshOnlyCustomers(); Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { customersView = new CustomersView(); customersView.CustomersVM = customersVM; frameCustomers.Content = customersView; var locationsView = new LocationsView(); frameLocations.Content = locationsView; NotVisibleColumns.Add(nameof(MachineInformation.ContactPerson)); dgMachineInformations.SelectionChanged += DgMachineInformations_SelectionChanged; dgMachineInformations.SelectedIndex = 0; AssigneValuesToControl(); customersView.expanderCustomers.Collapsed += ExpanderCustomers_Collapsed; customersView.dgCustomers.SelectionChanged += DgCustomers_SelectionChanged; locationsView.expanderLocations.Collapsed += ExpanderLocations_Collapsed; locationsView.dgLocations.SelectionChanged += DgLocations_SelectionChanged; masterDataInfo = new MasterDataInfoView(Helper.Helper.TTypeMangement.MachineInformation); masterDataInfo.cbLocations.SelectionChanged += CbLocations_SelectionChanged; masterDataInfo.RefreshCustomers(); frameMasterDataInfo.Content = masterDataInfo; })); }).ContinueWith((task) => { LoadingIndicatorPanel.Visibility = Visibility.Collapsed; gridResizableMachineInformation.IsEnabled = true; }, TaskScheduler.FromCurrentSynchronizationContext()); EnableContoles(false); }
public CustomersPage() { InitializeComponent(); BindingContext = viewModel = new CustomersViewModel(); }
public CustomersHistoryView(CustomersViewModel model) { InitializeComponent(); DataContext = model; }
public IActionResult Create(CustomersViewModel model) { var result = _customerServices.CreateCustomer(model); return(Json(result)); }
private void LoadData() { viewModel = CustomersViewModel.GetDefault(); CustomersList.ItemsSource = viewModel.GetAllItems(); }