/// <summary> /// Get Customers /// </summary> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortExpression"></param> /// <param name="sortDirection"></param> /// <param name="transaction"></param> /// <returns></returns> public List <Customer> GetCustomers(int currentPageNumber, int pageSize, string sortExpression, string sortDirection, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <Customer> customers = new List <Customer>(); try { int totalRows; _customerDataService.CreateSession(); customers = _customerDataService.GetCustomers(currentPageNumber, pageSize, sortExpression, sortDirection, out totalRows); _customerDataService.CloseSession(); transaction.TotalPages = ProjectFlotillas.Business.Common.Utilities.CalculateTotalPages(totalRows, pageSize); transaction.TotalRows = totalRows; transaction.ReturnStatus = true; } catch (Exception ex) { string errorMessage = ex.Message; transaction.ReturnMessage.Add(errorMessage); transaction.ReturnStatus = false; } finally { _customerDataService.CloseSession(); } return(customers); }
public CustomerValidator(ICustomerDataService customerDataService, Customer customer) { if (customer.CustomerCode != null && customer.CustomerCode.Trim().Length > 0) { customerDataService.CreateSession(); List <Customer> customers = customerDataService.GetCustomers(customer.CustomerCode); customerDataService.CloseSession(); foreach (Customer existingCustomer in customers) { if (existingCustomer.CustomerID != customer.CustomerID) { _validCustomerCode = false; break; } } } RuleFor(a => a.CustomerCode).NotEmpty().WithMessage("Customer Code is required."); RuleFor(a => a.CompanyName).NotEmpty().WithMessage("Company Name is required."); RuleFor(a => a.CompanyVorname).NotEmpty().WithMessage("CompanyVorname is required."); RuleFor(a => a.Salutation).NotEmpty().WithMessage("Salutation is required."); RuleFor(a => a.Photo).NotEmpty().WithMessage("Photo is required."); RuleFor(a => a.AddressLine1).NotEmpty().WithMessage("AddressLine1 is required."); RuleFor(a => a.City).NotEmpty().WithMessage("City is required."); RuleFor(a => a.ZipCode).NotEmpty().WithMessage("ZipCode is required."); RuleFor(a => a.State).NotEmpty().WithMessage("State is required."); RuleFor(a => a.PhoneNumber2).NotEmpty().WithMessage("PhoneNumber2 is required."); RuleFor(a => a.EMail).NotEmpty().WithMessage("EMail is required."); RuleFor(a => a.CustomerCode).Must(ValidateDuplicateCustomerCode).WithMessage("Customer Code already exists."); }
/// <summary> /// Get Customers /// </summary> /// <param name="customerCode"></param> /// <param name="companyName"></param> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortDirection"></param> /// <param name="sortExpression"></param> /// <param name="totalRows"></param> /// <returns></returns> public List <Customer> GetCustomers(string customerCode, string companyName, int currentPageNumber, int pageSize, string sortDirection, string sortExpression, out int totalRows, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <Customer> customers = new List <Customer>(); totalRows = 0; try { _customerDataService.CreateSession(); customers = _customerDataService.GetCustomers(customerCode, companyName, currentPageNumber, pageSize, sortDirection, sortExpression, out totalRows); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { _customerDataService.CloseSession(); } return(customers); }
private async Task Initialize() { var customers = await _customerDataService.GetCustomers(); CustomersCollection = new ObservableCollection <Customer>(customers); SelectedCustomer = CustomersCollection.FirstOrDefault(x => x.Id == Reestr.CustomerId); }
private async Task Initialize() { var rs = await _reestrSettingDataService.GetReestrSetting(); var collection = await _recipeDataService.GetRecipes(); var customers = await _customerDataService.GetCustomers(); var barrelNumber = await _barrelStorageDataService.GetLastBarrelNumber(rs.CurrentRecipe); RecipesCollection = new ObservableCollection <Recipe>(collection); CustomersCollection = new ObservableCollection <Customer>(customers); ReestrSetting = rs ?? new ReestrSetting(); SelectedRecipe = RecipesCollection.FirstOrDefault(x => x.Id == ReestrSetting.RecipeId); SelectedCustomer = CustomersCollection.FirstOrDefault(x => x.Id == ReestrSetting.CustomerId); ReestrSetting.InitialBarrelNumber = barrelNumber + 1; }
public CustomerBusinessRules(ICustomerDataService customerDataService, Customer customer) { if (customer.CustomerCode != null && customer.CustomerCode.Trim().Length > 0) { customerDataService.CreateSession(); List <Customer> customers = customerDataService.GetCustomers(customer.CustomerCode); customerDataService.CloseSession(); foreach (Customer existingCustomer in customers) { if (existingCustomer.CustomerID != customer.CustomerID) { _validCustomerCode = false; break; } } } RuleFor(a => a.CustomerCode).NotEmpty().WithMessage("Customer Code is required."); RuleFor(a => a.CompanyName).NotEmpty().WithMessage("Company Name is required."); RuleFor(a => a.CustomerCode).Must(ValidateDuplicateCustomerCode).WithMessage("Customer Code already exists."); }
private async Task Initialize() { var customers = await _customerDataService.GetCustomers(); CustomersCollection = new ObservableCollection <Customer>(customers); }