Esempio n. 1
0
        protected override void Seed(SynergyDbContext context)
        {
            context.Synergy_API.Add(new Synergy_Api()
            {
                Api = ApiTypes.AgileCrm.ToString()
            });
            context.Synergy_API.Add(new Synergy_Api()
            {
                Api = ApiTypes.Infusion.ToString()
            });
            context.Synergy_API.Add(new Synergy_Api()
            {
                Api = ApiTypes.HubSpot.ToString()
            });

            var Synergy_User = new Synergy_User()
            {
                IsActive = true, FirstName = "admin", LastName = "admin", UserRole = "admin"
            };

            context.Synergy_Users.Add(Synergy_User);
            context.SaveChanges();
            context.Synergy_Accounts.Add(new Synergy_Account()
            {
                IsActive = true, UserId = Synergy_User.UserId,
                Password = PasswordEncription.CreateSHAHash("BistroMDSystem"), UserName = "******"
            });
            context.SaveChanges();
            base.Seed(context);
        }
Esempio n. 2
0
 private static bool LoginUser(string username, string password)
 {
     using (var context = new SynergyDbContext())
     {
         var hasValue = PasswordEncription.CreateSHAHash(password);
         var user     = context.Synergy_Accounts.Where(x => x.UserName == username && x.Password == hasValue).FirstOrDefault();
         if (user != null)
         {
             FormsAuthentication.SetAuthCookie(user.UserId.ToString(), false);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 3
0
 private static void Add(Synergy_User user, string username)
 {
     using (var _context = new SynergyDbContext())
     {
         _context.Synergy_Users.Add(user);
         _context.SaveChanges();
         Synergy_Account account = new Synergy_Account()
         {
             IsActive = true,
             Password = PasswordEncription.CreateSHAHash("Pa$$word"),
             UserName = username,
             UserId   = user.UserId
         };
         _context.Synergy_Accounts.Add(account);
         _context.SaveChanges();
     }
 }