PageRenderTime 33ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/yoyo/CardInChinaNew/CardInChina.Data.Entity/Entity/Partail/Customer.cs

#
C# | 62 lines | 54 code | 7 blank | 1 comment | 6 complexity | 9fd321146e0d88b5594241ebcdbf1c69 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Reflection;
  6. using System.ComponentModel.DataAnnotations;
  7. namespace CardInChina.Data.Entity.Entity
  8. {
  9. public partial class Customer
  10. {
  11. public Customer Load<T>()
  12. {
  13. using (CICEntities db = new CICEntities())
  14. {
  15. Customer customer = db.Customers.FirstOrDefault(c => c.CustomerID == this.CustomerID);
  16. PropertyInfo[] pis = typeof(Customer).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);
  17. foreach (var p in pis)
  18. {
  19. if (p.PropertyType == typeof(T))
  20. p.GetValue(customer, null);
  21. }
  22. return customer;
  23. }
  24. }
  25. public string GetDisplayName()
  26. {
  27. if (!string.IsNullOrEmpty(DisplayName))
  28. return DisplayName;
  29. else
  30. return Account;
  31. }
  32. public string GenerateVerifyCode()
  33. {
  34. //sql="update customer set very_code=MD5(cust_id+balance+325.61)"
  35. return MySqlFunctions.MD5((CustomerID + (double)Balance + 325.61).ToString("F"));
  36. }
  37. [NotMapped]
  38. public bool IsActivated
  39. {
  40. get { return IsActived != 0; }
  41. set { IsActived = (sbyte)(value ? 1 : 0); }
  42. }
  43. [NotMapped]
  44. public bool HasPaypalAccount
  45. {
  46. get { return PaypalAccount != null; }
  47. }
  48. [NotMapped]
  49. public bool IsVipCustomer
  50. {
  51. get { return IsVip.HasValue ? IsVip.Value : false; }
  52. set { IsVip = value; }
  53. }
  54. }
  55. }