Exemplo n.º 1
0
        public bool AddStationUser(UserRegistrationObj userRegistrationObj, ref string reply, ref UserRegResponse userResp)
        {
            if (userRegistrationObj == null)
            {
                reply = "Invalid User Information";
                return(false);
            }

            try
            {
                var response = _client.PostAsJsonAsync("api/StationUser/AddUserDetail", userRegistrationObj).Result;
                if (response.IsSuccessStatusCode)
                {
                    var data             = response.Content.ReadAsStringAsync().Result;
                    var questionResponse = JsonConvert.DeserializeObject <UserRegResponse>(data);
                    if (questionResponse.Status.IsSuccessful == false)
                    {
                        reply = questionResponse.Status.Message.FriendlyMessage;
                        return(false);
                    }
                    reply    = null;
                    userResp = questionResponse;
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                reply = ex.Message;
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        private void Intialiazer()
        {
            try
            {
                var beneficiaryBiometrics = new BeneficiaryRepository().GetBeneficiarys();
                if (!beneficiaryBiometrics.Any())
                {
                }


                //var beneficiary = new BeneficiaryRepository().GetBeneficiary(1);
                //if (beneficiary == null || beneficiary.BeneficiaryId < 1)
                //{

                //}


                var pathString = ConfigurationManager.AppSettings["BioResource"];
                var appDir     = InternetCon.GetBasePath();
                var root       = Path.GetPathRoot(pathString);
                var imagePath  = Path.GetFullPath(appDir + pathString);


                #region Verification
                #endregion



                var bioMetricInfo = new BeneficiaryRepository().GetBeneficiaryBiometric(1);

                var companyInfo = new CorporateInfoService().GetCompanyInfos();
                if (companyInfo.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var userList = new UserService().GetUsers();
                if (userList.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }


                var station = new StationInfoService().GetStationInfos();
                if (station.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                //var dir = InternetCon.GetBasePath() + ConfigurationManager.AppSettings["BiometricResource"];


                var userProfiles = new UserProfileRepository().GetUserProfiles();
                if (userProfiles.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var localAreas = new LocalAreaRepository().GetLocalAreas();
                if (localAreas.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }



                _apiHelper = new WebAPIHelper(_api);
                List <RegisteredUserReportObj> users = null;
                string reply = null;


                #region POST Request - Add User Details

                var roleList = new List <NameAndValueObject>
                {
                    new NameAndValueObject {
                        Id = 1, Name = "My Admin"
                    }
                };

                var resp = new UserRegResponse();

                var selRoles = new[] { "1" }.ToList();
                var roleIds = new[] { 1 };

                var helper = new UserRegistrationObj
                {
                    ConfirmPassword    = "******",
                    Email              = "*****@*****.**",
                    Othernames         = "Adesoji",
                    Surname            = "Ilesanmi",
                    MobileNumber       = "08036975694",
                    MyRoleIds          = roleIds,
                    MyRoles            = selRoles.ToArray(),
                    Username           = "******",
                    Password           = "******",
                    SelectedRoles      = string.Join(";", selRoles),
                    Sex                = 1,
                    RegisteredByUserId = 1,
                };

                if (_apiHelper.AddStationUser(helper, ref reply, ref resp))
                {
                    if (resp == null || resp.UserId < 1)
                    {
                        return;
                    }
                }

                #endregion


                //var userList = Controller.DownLoadStationUsers();



                if (_apiHelper.GetStationUsers(ref reply, ref users))
                {
                    if (users == null || !users.Any())
                    {
                        return;
                    }
                    var total = users.Count();
                }

                //var context = new BioEnumeratorEntities();
                //InternetCon.ProcessLookUpFromFiles(context);

                string msg;

                var delState = new StateRepository().DeleteState(37);
                if (delState.IsSuccessful)
                {
                    MessageBox.Show(@"State Deleted Successfully", @"Record Deletion");
                }

                //var intit = eDataAdminLite.API.MigrationAssistance.Migrate(out msg);
                //if (intit)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                //var st = new StateRepository().GetState(37);
                //if (st != null && st.StateId > 0)
                //{
                //    st.Name = "Epay Plus Limited";
                //}

                //var updateState = new StateRepository().UpdateState(st);
                //if (updateState.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"State Update successfully");
                //}


                //var state = new State
                //{
                //    Name = "Epay Plus",
                //};
                //var retVal = new StateRepository().AddState(state);
                //if (retVal.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                var states = new StateRepository().GetStates();
                if (states.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }

                var roles = new RoleRepository().GetRoles();
                if (roles.Any())
                {
                    MessageBox.Show(@"Database Initializer", @"Configuration");
                }



                //var retVal = eDataAdminLite.API.UserManager.AddRole(role);
                //if (retVal.IsSuccessful)
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}

                //var roles = eDataAdminLite.API.UserManager.GetRoles();
                //if (!roles.Any())
                //{
                //    MessageBox.Show(@"Database Initializer", @"Configuration");
                //}
            }
            catch (Exception)
            {
                throw;
            }
        }