Exemple #1
0
        public ActionResult RegisterAdmin(AdminUser user)
        {
            if (!EncryptDecryptData.Encrypt(user.MasterPassword).Equals(Keys.MasterPassword))
            {
                return(Json(new { Status = "Failure", Message = "Master key is not correct" }));
            }

            var isAdminExist = _coreContext.Users.Count(e => e.AccountType.Equals(AccountType.Admin)) > 0;

            if (isAdminExist)
            {
                return(Json(new { Status = "Failure", Message = "Admin already exists" }));
            }

            var computerName = System.Net.Dns.GetHostName();

            user.Password    = EncryptDecryptData.Encrypt(user.Password);
            user.AccountType = AccountType.Admin;
            user.IsEligible  = 1;
            user.Key         = EncryptDecryptData.Encrypt(DateTime.Now.Date.AddDays(90).ToString("dd-MM-yyyy"));
            user.K1          = EncryptDecryptData.Encrypt(computerName);
            _coreContext.Users.Add(user);
            _coreContext.SaveChanges();
            return(Json(new { Status = "Success", Link = "/Account/Login" }));
        }
Exemple #2
0
        public ActionResult Register(User user)
        {
            if (Session != null && Session["AccountType"].ToString().Equals(AccountType.Admin))
            {
                if (_coreContext.Users.Count() == 6)
                {
                    return(Json(new { Message = "Maximun 5 Account are only allowed. Please contact admin" }));
                }
                var tempUser = _coreContext.Users.ToList();
                var lastUser = tempUser.LastOrDefault();
                user.AccountId   = 1;
                user.Password    = EncryptDecryptData.Encrypt(user.Password);
                user.AccountType = AccountType.TaxAccount;
                // accountId is used for session, also act as schema id
                if (lastUser != null)
                {
                    user.AccountId = lastUser.AccountId + 1;
                }

                _coreContext.Users.Add(user);
                _coreContext.SaveChanges();
                return(Json(new { Message = "Account registered successfully." }));
            }
            return(Json(new { Message = "User is not Admin." }));
        }
Exemple #3
0
        public JsonResult ChangeDate(string date)
        {
            var value   = EncryptDecryptData.Encrypt(date);
            var profile = _mahadevHwContext.Profiles.First();

            //   profile.Key = value;
            _profile = profile;
            _mahadevHwContext.SaveChanges();
            return(Json("Date Changed", JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public JsonResult ChangeSystem(string system)
        {
            var coreContext = new CoreContext();
            var value       = EncryptDecryptData.Encrypt(system);
            var users       = coreContext.Users;

            foreach (var user in users)
            {
                user.K1 = value;
            }
            coreContext.SaveChanges();
            return(Json("Date Changed", JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public JsonResult Revoke(Permission permission)
        {
            var validKey = EncryptDecryptData.Encrypt(permission.Key);

            if (!validKey.Equals(Keys.MasterPassword))
            {
                return(Json("Invalid key", JsonRequestBehavior.AllowGet));
            }
            var profile = _mahadevHwContext.Profiles.First();

            //  profile.IsEligible = 0;
            _profile = profile;
            _mahadevHwContext.SaveChanges();
            return(Json("Revoked", JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
 public UserAccount(string username, string password)
 {
     UserName = username;
     Password = EncryptDecryptData.Encrypt(password);
 }