/// <summary> /// Gets a value indicating whether customer is in a certain customer role /// </summary> /// <param name="customer">Customer</param> /// <param name="customerRoleSystemName">Customer role system name</param> /// <param name="onlyActiveCustomerRoles">A value indicating whether we should look only in active customer roles</param> /// <returns>Result</returns> public static bool IsInCustomerRole(this Customers.Customer customer, string customerRoleSystemName, bool onlyActiveCustomerRoles = true) { if (customer == null) { throw new ArgumentNullException("customer"); } if (String.IsNullOrEmpty(customerRoleSystemName)) { throw new ArgumentNullException("customerRoleSystemName"); } var result = customer.CustomerRole.SystemName == customerRoleSystemName; return(result); }
/// <summary> /// Determines whether [is in customer power] [the specified customer power system name]. /// </summary> /// <param name="customer">The customer.</param> /// <param name="customerPowerSystemName">Name of the customer power system.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// customer /// or /// customerPowerSystemName /// </exception> public static bool IsInCustomerPower(this Customers.Customer customer, string customerPowerSystemName) { if (customer == null) { throw new ArgumentNullException("customer"); } if (String.IsNullOrEmpty(customerPowerSystemName)) { throw new ArgumentNullException("customerPowerSystemName"); } var result = customer.CustomerRole.PermissionRecords.FirstOrDefault( d => d.SystemName == customerPowerSystemName) != null; return(result); }
private void popupContainerEdit1_QueryResultValue(object sender, DevExpress.XtraEditors.Controls.QueryResultValueEventArgs e) { if (e.Value == null) { return; } if (e.Value.GetType().Equals(typeof(DataRow))) { Customers.Customer cr = new Customers.Customer(((DataRow)e.Value).Field <int>("CustomerID")); e.Value = cr; } else if (e.Value.GetType().Equals(typeof(Customers.Customer))) { } else { e.Value = null; } }
/// <summary> /// Gets a value indicating whether customer is administrator /// </summary> /// <param name="customer">Customer</param> /// <param name="onlyActiveCustomerRoles">A value indicating whether we should look only in active customer roles</param> /// <returns>Result</returns> public static bool IsAdmin(this Customers.Customer customer, bool onlyActiveCustomerRoles = true) { return(IsInCustomerRole(customer, SystemCustomerRoleNames.Administrators, onlyActiveCustomerRoles)); }
private Customers.Customer getCustomer(string CustomerID) { if (!CustomerDB.Elements("Customer").Any()) return new Customers.Customer(); if (CustomerDB.Elements("Customer").Any(x => x.Element("CustomerID").Value == CustomerID)) { var sw = new Performance.Stopwatch("GetCustomer (" + CustomerID + ")"); sw.Start(); var temp = new Customers.Customer(); var xitem = CustomerDB.Elements("Customer").Single(x => x.Element("CustomerID").Value == CustomerID); temp.ParseFromXElement(xitem); if (paymentMethodesList().Any(x => x.Name == xitem.Element("DefaultPaymentMethode").Value)) temp.DefaultPaymentMethode = paymentMethodesList().First(x => x.Name == xitem.Element("DefaultPaymentMethode").Value); sw.Stop(); sw.PrintResultToConsole(); logger.Trace(sw.Result()); return temp; } else return new Customers.Customer(); }