Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. #### AdherentService fel proejt service
  2. public class AdherentService:Service<adherent>, IAdherentService
  3. {
  4.  
  5. static IDataBaseFactory Factory = new DataBaseFactory();
  6. static IUnitOfWork unitOfWork = new UnitOfWork(Factory);
  7. public AdherentService() : base(unitOfWork)
  8. {
  9. }
  10.  
  11.  
  12.  
  13. #### IAdherentService interface fel projet service
  14. public interface IAdherentService : IService<adherent>
  15. {
  16.  
  17. }
  18.  
  19.  
  20. ### tji mabad lel controlleur
  21. par exemple andi ena
  22. public class SignUpMoraleController : Controller
  23. ndeclari el service w n'instancih fel constructeur
  24.  
  25. IAdherentService adherentService;
  26.  
  27. public SignUpPhysiqueController()
  28. {
  29. adherentService = new AdherentService();
  30. }
  31.  
  32.  
  33. // POST: SignUpPhysique/Create
  34. [HttpPost]
  35. public ActionResult Create(AdherentPhysiqueVM adherentPhysiqueVM, HttpPostedFileBase file, HttpPostedFileBase file2)
  36. {
  37.  
  38. adherent adh = new adherent()
  39. { adresse= adherentPhysiqueVM.adresse,
  40. categorieAbonnement = adherentPhysiqueVM.categorieAbonnement,
  41. cin = adherentPhysiqueVM.cin,
  42. codePostal= adherentPhysiqueVM.codePostal,
  43.  
  44. DTYPE="AdhPhysique",
  45. email= adherentPhysiqueVM.email,
  46. lieuNaissance= adherentPhysiqueVM.lieuNaissance,
  47. solde=0,
  48. rib= adherentPhysiqueVM.rib,
  49. nbPoints=0,
  50. dateAdhesion= DateTime.Now,
  51. dateDerniereCotisation = DateTime.Now,
  52. etatCompte =(int)EtatCompte.NonConfirme,
  53.  
  54. telephone= adherentPhysiqueVM.telephone,
  55. ville= adherentPhysiqueVM.ville,
  56. dateNaissance= adherentPhysiqueVM.dateNaissance,
  57. etatAdherent=(int)EA.Vivant,
  58. etatCivil= adherentPhysiqueVM.etatCivil,
  59. nationalite= adherentPhysiqueVM.nationalite,
  60. nbEnfants= adherentPhysiqueVM.nbEnfants,
  61. nom= adherentPhysiqueVM.nom,
  62. prenom= adherentPhysiqueVM.prenom,
  63. pseudonyme= adherentPhysiqueVM.pseudonyme,
  64.  
  65. motDePasse = encryptedPassword(adherentPhysiqueVM.motDePasse),
  66.  
  67. idAdherent =HibernateSequenceManager.getCurrentHibernateSequence()
  68.  
  69. };
  70.  
  71.  
  72.  
  73.  
  74. if (file != null && file.ContentLength > 0 && file2 != null && file2.ContentLength > 0)
  75. {
  76. var fileName = Path.GetFileName(file.FileName);
  77. var fileName2 = Path.GetFileName(file2.FileName);
  78. string location = "C:\\wamp64\\www\\OTDAV\\";
  79.  
  80. //create a folder
  81. DirectoryInfo di = Directory.CreateDirectory(location + adh.cin);
  82. //store the file
  83. file.SaveAs(location + adh.cin + "\\" + file.FileName);
  84. file2.SaveAs(location + adh.cin + "\\" + file2.FileName);
  85. }
  86.  
  87. adh.copieCin = adh.cin + "/"+ file.FileName;
  88. adh.photoProfil = adh.cin + "/" + file2.FileName;
  89.  
  90.  
  91.  
  92. adherentService.Add(adh);
  93. adherentService.Commit();
  94.  
  95. HibernateSequenceManager.incrementHibernateSequence();
  96.  
  97.  
  98. return View();
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement