Esempio n. 1
0
 public static Matchmaker RegisterMatchmaker(Matchmaker matchmaker)
 {
     try
     {
         var role    = db.roles.First(p => p.Name == "MatchMarker");
         var roleDto = Converters.Convert(role);
         matchmaker.Worker.User.Roles = new List <Role>();
         matchmaker.Worker.User.Roles.Add(roleDto);
         var user = UserBL.Register(matchmaker.Worker.User);
         matchmaker.Worker.UserId     = user.Id;
         matchmaker.Worker.User       = null;
         matchmaker.Worker.CreateDate = DateTime.Now;
         matchmaker.Worker.UpdateDate = DateTime.Now;
         var matchmakerDB = Converters.Convert(matchmaker);
         matchmakerDB.worker.bank   = null;
         matchmakerDB.worker.BankId = null;
         var matchmakerInter = db.matchmakers.Add(matchmakerDB);
         db.SaveChanges();
         return(Converters.Convert(matchmakerInter));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 2
0
 public static Helper RegisterHelper(Helper helper)
 {
     try
     {
         var role    = db.roles.First(p => p.Name == "Worker");
         var roleDto = Converters.Convert(role);
         helper.Worker.User.Roles.Add(roleDto);
         var user = UserBL.Register(helper.Worker.User);
         helper.Worker.UserId = user.Id;
         var helperDB    = Converters.Convert(helper);
         var helperInter = db.helpers.Add(helperDB);
         db.SaveChanges();
         return(Converters.Convert(helperInter));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }