Пример #1
0
        public dynamic StaffResetPassword(int StaffID)
        {
            FuelFillingStaff objStaff = _repositoryWrapper.FuelFillingStaff.FindByID(StaffID);
            string           Password = "";
            string           salt     = "";
            string           PWD      = "";
            dynamic          objresponse;

            objresponse = new { data = false };

            if (objStaff != null)
            {
                //Password = "******"; //Operational.Cryptography.RandomPassword.Generate();
                var settingresult = (_repositoryWrapper.Setting.GetPasswordValidation()).ToList();
                var pwdlength     = settingresult[0].Value;
                Password = Operational.Cryptography.RandomPassword.Generate(int.Parse(pwdlength));

                if (Password != "")
                {
                    salt = objStaff.salt;
                    PWD  = Operational.Encrypt.SaltedHash.ComputeHash(salt, Password);
                    objStaff.password = PWD;
                    _repositoryWrapper.FuelFillingStaff.Update(objStaff);

                    _repositoryWrapper.EventLog.Info("Success");
                    objresponse = new { data = Password };
                }
            }

            return(objresponse);
        }
Пример #2
0
        public dynamic SaveStaff([FromBody] Newtonsoft.Json.Linq.JObject param)
        {
            dynamic obj         = param;
            dynamic objresponse = null;
            int     StaffID     = obj.StaffID != null ? obj.StaffID : 0;
            string  CompanyID   = _tokenData.CompanyID;

            try
            {
                var cusobj = _repositoryWrapper.FuelFillingStaff.FindByID(StaffID);
                if (cusobj != null)
                {
                    cusobj.staffname    = obj.name;
                    cusobj.code         = obj.code;
                    cusobj.username     = obj.username;
                    cusobj.email        = obj.Email;
                    cusobj.township     = obj.TownshipID;
                    cusobj.state        = obj.StateID;
                    cusobj.address      = obj.Address;
                    cusobj.phone        = obj.Phone;
                    cusobj.modifieddate = System.DateTime.Now;
                    cusobj.inactive     = true;
                    _repositoryWrapper.FuelFillingStaff.Update(cusobj);
                    _repositoryWrapper.EventLog.Update(cusobj);
                }
                else
                {
                    var newobj = new FuelFillingStaff();
                    newobj.staffname     = obj.name;
                    newobj.code          = obj.code;
                    newobj.username      = obj.username;
                    newobj.email         = obj.Email;
                    newobj.township      = obj.TownshipID;
                    newobj.state         = obj.StateID;
                    newobj.address       = obj.Address;
                    newobj.phone         = obj.Phone;
                    newobj.modifieddate  = System.DateTime.Now;
                    newobj.inactive      = true;
                    newobj.access_status = 0;
                    var password      = obj.Password;
                    var settingresult = _repositoryWrapper.Setting.GetPasswordValidation().ToList();
                    var pwdlength     = settingresult[0].Value;

                    /* if (password.ToString().Length < int.Parse(pwdlength))
                     * {
                     *  StaffID = -3;
                     * } */
                    /*  else
                     * { */
                    string salt = Operational.Encrypt.SaltedHash.GenerateSalt();
                    password        = Operational.Encrypt.SaltedHash.ComputeHash(salt, password.ToString());
                    newobj.password = password;
                    newobj.salt     = salt;
                    _repositoryWrapper.FuelFillingStaff.Create(newobj);
                    _repositoryWrapper.FuelFillingStaff.Save();

                    //}
                    StaffID = newobj.staffID;
                    _repositoryWrapper.EventLog.Insert(newobj);
                }
                objresponse = new { data = StaffID };
            }
            catch (ValidationException vex)
            {
                _repositoryWrapper.EventLog.Error("Customer Controller/ Save Customer", vex.Message);
                objresponse = new { data = 0, error = vex.ValidationResult.ErrorMessage };
                Console.WriteLine(vex.Message);
            }

            return(objresponse);
        }