コード例 #1
0
        public async Task <IActionResult> GetUserAsync([FromHeader] string Authorization, [FromBody] UserCred userCred)
        {
            string email       = tokenObj.GetNameClaims(Authorization);
            string password    = userCred.Password;
            string newPassword = userCred.newPassword;


            if (email == "" || password == "" || newPassword == "")
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }

            User user = await UserMethods.getUser(email);

            if (user == null)
            {
                return(NotFound(JsonConvert.SerializeObject("User does not exist", Formatting.Indented)));
            }

            if (!UserMethods.authUser(email, password))
            {
                return(NotFound(JsonConvert.SerializeObject("Wrong Password", Formatting.Indented)));
            }

            if (!(await UserMethods.ChangePass(email, password, newPassword)))
            {
                return(NotFound(JsonConvert.SerializeObject("Something went wrong", Formatting.Indented)));
            }

            string json = JsonConvert.SerializeObject("Password changed!", Formatting.Indented);

            return(Ok(json));
        }
コード例 #2
0
        public async Task <IActionResult> GetWatchlistAsync([FromHeader] string Authorization)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            string email = tokenObj.GetNameClaims(Authorization);

            if (email == "")
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "Please enter all fields");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            if (await UserMethods.getUser(email) == null)
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "User not found");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }


            List <MovieFirebase> wl = await WatchListMethods.GetMoviesAsync(email);

            if (wl.Count == 0 || wl == null)
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "WatchList is empty");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            string json = JsonConvert.SerializeObject(wl, Formatting.Indented);

            return(Ok(json));
        }
コード例 #3
0
        public async Task <IActionResult> PostUserAsync([FromBody] UserCred userCred)
        {
            var name     = userCred.Name;
            var email    = userCred.Email;
            var password = userCred.Password;

            // validate fields
            if (name == null || email == null || password == null)
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }


            // check  if user exists
            if (await UserMethods.getUser(email) != null)
            {
                return(NotFound(JsonConvert.SerializeObject("User already exists", Formatting.Indented)));
            }

            //check if user saved
            bool savedUser = await UserMethods.insertUserAsync(name, email, password);

            if (!savedUser)
            {
                return(NotFound(JsonConvert.SerializeObject("Something went wrong saving the user", Formatting.Indented)));
            }

            return(Ok("200: description: Successfully inserted user"));
        }
コード例 #4
0
        public async Task <IActionResult> LoginAsync([FromBody] UserCred userCred)
        {
            var email    = userCred.Email;
            var password = userCred.Password;


            //validate fields
            if (email == "" || password == "")
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }
            //validate user
            var token = jwtAuthenticationManager.Authenticate(email, password);

            if (token == null)
            {
                return(Unauthorized(JsonConvert.SerializeObject("Invalid credentials", Formatting.Indented)));
            }

            User user = await UserMethods.getUser(email);

            tokenObj      sendToken = new tokenObj(token);
            List <object> objects   = new List <object>();

            user.UserPassword = null;
            objects.Add(sendToken);
            objects.Add(user);
            return(Ok(JsonConvert.SerializeObject(objects, Formatting.Indented)));
        }
コード例 #5
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact]//Repository.HaikuRepo.cs
        public void HaikuRepoTest3()
        {
            HaikuRepo haikurepo = new HaikuRepo(hContext);
            HaikuLine haikuline = new HaikuLine();

            haikuline.Line     = "I can not live without it";
            haikuline.Tags     = "life silly";
            haikuline.Syllable = 7;
            haikuline.Approved = true;
            haikuline.Username = "******";
            RawUser rawuser = new RawUser();

            rawuser.Username  = "******";
            rawuser.FirstName = "Chris";
            rawuser.LastName  = "Larson";
            rawuser.Password  = "******";
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        user        = usermethods.GetUser(rawuser.Username);

            haikuline.User = user;
            var actual   = haikurepo.SaveLine(haikuline).Username;
            var expected = "Chris123";

            Assert.Equal(expected, actual);
        }
コード例 #6
0
        async void OnbtnLoginClicked(object sender, EventArgs e)
        {
            var m = new UserMethods();

            if (g.signIn)
            {
                var s = await m.SignOut(g);
            }
            else
            {
                var mth = new Methodlar();


                if (g.signIn)
                {
                }
                else
                {
                    if (g.checkDbUser)
                    {
                        g.usernameEntry.Text = g.user.user;
                        g.passwordEntry.Text = g.user.pass;
                        g.custEntry.Text     = g.user.cust;
                        g.cpssEntry.Text     = g.user.cpss;
                        g.rememberSwt.On     = g.user.remember;
                        g.savepassSwt.On     = g.user.save;
                    }


                    LoginPage loginp = new LoginPage(g);

                    await g.mdp.Detail.Navigation.PushAsync(loginp);
                }
            }
        }
コード例 #7
0
        public void AddStudent(String StudentName, String StudentAdress, String StudentMail, String StudentPhone, String StudentUsername, String Password, String CourseId)
        {
            User user = new User();

            user.FullName    = StudentName;
            user.Adress      = StudentAdress;
            user.UserID      = Guid.NewGuid();
            user.StudentID   = Guid.NewGuid();
            user.Password    = Password;
            user.Mail        = StudentMail;
            user.Username    = StudentUsername;
            user.PhoneNumber = StudentPhone;
            Student stu = new Student();

            stu.StudentId = (Guid)user.StudentID;
            stu.GPA       = 0;
            Transcript trans = new Transcript();

            trans.cid      = Int32.Parse(CourseId);
            trans.GPA      = 0;
            trans.Semester = "2018 Fall";
            stu.Transcript.Add(trans);
            user.Student = stu;
            var result = UserMethods.AddUser(user);

            if (result == true)
            {
                ViewBag.Added = true;
            }
            Response.Redirect("/Teacher/RegisterStudent");
        }
コード例 #8
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact]//Repository.HaikuRepo.cs
        public void HaikuRepoTest1()
        {
            HaikuRepo haikurepo = new HaikuRepo(hContext);
            HaikuLine haikuline = new HaikuLine();

            haikuline.Line     = "Coffee is my life";
            haikuline.Tags     = "coffee life silly";
            haikuline.Syllable = 5;
            haikuline.Approved = false;
            haikuline.Username = "******";
            RawUser rawuser = new RawUser();

            rawuser.Username  = "******";
            rawuser.FirstName = "Chris";
            rawuser.LastName  = "Larson";
            rawuser.Password  = "******";
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        user        = usermethods.UserRegister(rawuser);

            haikuline.User = user;
            var actual   = haikurepo.SaveLine(haikuline).Username;
            var expected = "Chris123";

            Assert.Equal(expected, actual);
        }
コード例 #9
0
 public static void ClassInit(TestContext testContext)
 {
     user = new UserMethods(debugLog);
     XmlConfigurator.Configure();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
 }
コード例 #10
0
        public ActionResult UpdateProfile(tbl_Users request, int?RequestId = null)
        {
            //var flag = new UserDataAccess().UpdateUser(request);
            var getUserDetails   = UserMethods.GetUserDetailsByID(request.ID);
            var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault());

            request.UserPassword          = getUserDetails.UserPassword;
            request.AuthorizationStatus   = getUserDetails.AuthorizationStatus;
            request.AuthorizationComments = getUserDetails.AuthorizationComments;

            var existingJson = getUserDetails == null ? null : CustomHelper.GetJson(getUserDetails);

            var updatedJson = CustomHelper.GetJson(request);
            var row         = new tbl_System_Requests
            {
                ID = RequestId ?? 0,
                AuthorizationStatus   = "P",
                CreatorID             = StateHelper.UserId,
                IsActive              = true,
                ExistingData          = existingJson,
                UpdatedData           = updatedJson,
                RequestType           = Constants.RequestTypes.UserModification,
                AuthorizerID          = getSystemRequest?.AuthorizerID ?? 0,
                AuthorizationComments = getSystemRequest?.AuthorizationComments ?? string.Empty
            };

            var flag = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row);

            return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? CustomMessages.UserProfileUpdateSuccessfully : CustomMessages.GenericErrorMessage }, JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
        void OnbtnChangePassClicked(object sender, EventArgs e)
        {
            ServiceManager sm = new ServiceManager();
            var            m  = new UserMethods();


            if (g.usernameEntry.Text == "" || g.passwordEntry.Text == "")
            {
                this.DisplayAlert("User Name Error", "Please Enter your POSDA account name", "OK");
            }
            else
            {
                g = m.dbCheckUser(g).Result;

                //var signResult = m.SignInOut(g, 0).Result;

                if (g.signIn)
                {
                    ChangePassPage cp = new ChangePassPage(g);

                    g.mdp.Detail.Navigation.PushAsync(cp);
                }
                //else
                //{
                //    await parentpage.DisplayAlert("Error", "Failed Sign In", "OK");

                //}
            }
        }
コード例 #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //if (Application["user"] != null)
         //{
         if (!string.IsNullOrEmpty(Request.QueryString["Code"]))
         {
             this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserEditdiv();", true);
             UserInfo info          = UserMethods.GetUserByCode(Request.QueryString["Code"]);
             string   desecpassword = FBJHelper.Encryption.DESEdcrypt(info.Password, "19850627");
             info.Password = desecpassword;
             Initialize(info);
         }
         else
         {
             this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserSet();", true);
         }
         BindDataGrid(queryList);
         //}
         //else
         //{
         //    Response.Redirect("~/Views/Login.aspx");
         //    Alert.Show(this, "请先登录!");
         //}
     }
 }
コード例 #13
0
        protected void UserListDataGrid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string id = string.Empty;

            if (e.CommandName == "ImageDelete")
            {
                int selectindex = e.Item.ItemIndex;
                id = this.UserListDataGrid.Items[selectindex].Cells[0].Text;
            }
            if (!string.IsNullOrEmpty(id) && this.deleteflag == true)
            {
                int iSuccess = UserMethods.DeleteUser(Convert.ToInt32(id));
                if (iSuccess > 0)
                {
                    Alert.Show(this, "删除成功!");
                }
                else
                {
                    Alert.Show(this, "删除失败!");
                }
                if (queryList == null)
                {
                    queryList = new List <QueryElement>();
                }
                BindDataGrid(queryList);
            }
        }
コード例 #14
0
        public ActionResult Resources()
        {
            ViewBag.User = (User)Session["User"];
            User user = (User)Session["User"];

            ViewBag.Resources = UserMethods.GetResources(user.UserID);
            return(View("Resources"));
        }
コード例 #15
0
        public ActionResult VacationDays()
        {
            User user = (User)Session["User"];

            ViewBag.User        = (User)Session["User"];
            ViewBag.VacationDay = UserMethods.GetVacationDays(user.UserID);
            return(View("VacationDays"));
        }
コード例 #16
0
        public ActionResult ListForumEntries(int forumid)
        {
            ViewBag.User = (User)Session["User"];
            var result = UserMethods.GetForumEntries(forumid);

            ViewBag.ForumContent = result;
            return(View("ForumTopic"));
        }
コード例 #17
0
        public MasterDetail()
        {
            var glb = new POSDA.GlobalVar.GlobalDegisken();
            var mth = new Methodlar();
            var um  = new UserMethods();

            glb.mdp         = this;
            glb.datePeriod  = 2;
            glb.signIn      = false;
            glb.checkDbUser = false;


            try
            {
                glb = um.dbCheckUser(glb).Result;

                if (glb.checkDbUser)
                {
                    if (glb.user.save)
                    {
                        glb = um.SignIn(glb).Result;

                        if (glb.signIn)
                        {
                        }
                        else
                        {
                            int i = um.SignOut(glb).Result;
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Master = new MenuPage(glb)
                {
                    Title           = " ",
                    Padding         = new Thickness(0, Device.OS == TargetPlatform.iOS ? 20 : 0, 0, 0),
                    BackgroundColor = Color.Aqua
                };
                WelcomePage wp = new WelcomePage(glb);
                glb.activep = wp;
                glb.prevp   = null;
                Detail      = new NavigationPage(wp)
                {
                    BarBackgroundColor = Color.Aqua,
                    BarTextColor       = Color.Black,
                    Padding            = new Thickness(5, Device.OS == TargetPlatform.iOS ? 20 : 0, 5, 5),
                };
            }
        }
コード例 #18
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact] //BusinessLogic.UserMethods.cs
        public void UserMethodsTest3()
        {
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            var         expected    = false;
            var         actual      = usermethods.UpdatePassword("clarson", "123cherrytree", "99redballoons");

            Assert.Equal(expected, actual);
        }
コード例 #19
0
        public ActionResult ListForums()
        {
            ViewBag.User = (User)Session["User"];
            User user   = (User)Session["User"];
            var  result = UserMethods.GetForums(user.UserID);

            ViewBag.Forums = result;
            return(View("Forums"));
        }
コード例 #20
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact] //BusinessLogic.UserMethods.cs
        public void UserMethodsTest2()
        {
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        expected    = null;
            User        actual      = usermethods.UserLogin("clarson217", "12345");

            Assert.Equal(expected, actual);
        }
コード例 #21
0
 private void BindDataGrid(List <QueryElement> list)
 {
     userColl = UserMethods.GetUser(list);
     this.UserListDataGrid.DataSource = userColl;
     this.UserListDataGrid.DataBind();
     for (int i = 0; i < userColl.Count; i++)
     {
         this.UserListDataGrid.Items[i].Cells[4].Text = StaticRescourse.DisplayRole(userColl[i].Role);
     }
 }
コード例 #22
0
        static void Main(string[] args)
        {
            StringMethods stringMethods = new StringMethods();
            UserMethods   userMethods   = new UserMethods(stringMethods);

            Client client = new Client(stringMethods, userMethods);
            Chat   chat   = new Chat(stringMethods, userMethods);

            chat.P2PChat(client);
        }
コード例 #23
0
 public ActionResult Schedule(string uid = null)
 {
     if (uid == null)
     {
         User user = (User)Session["User"];
         ViewBag.User         = (User)Session["User"];
         ViewBag.ScheduleList = UserMethods.GetSchedule(user.UserID);
         return(View("Schedule"));
     }
 }
コード例 #24
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact]//Controllers.UserController.cs
        public void UserControllerTest5()
        {
            UserRepo       userrepo       = new UserRepo(hContext);
            UserMethods    userMethods    = new UserMethods(userrepo);
            UserController userController = new UserController(userMethods);
            var            actionList     = userController.GellAllUser();
            var            expected       = true;
            var            actual         = (actionList.Value.ToList() != null);

            Assert.Equal(expected, actual);
        }
コード例 #25
0
ファイル: UnitTests.cs プロジェクト: clcheatle/HaikuWriter
        [Fact]//Controllers.UserController.cs
        public void UserControllerTest3()
        {
            UserRepo       userrepo       = new UserRepo(hContext);
            UserMethods    userMethods    = new UserMethods(userrepo);
            UserController userController = new UserController(userMethods);
            var            actionUser     = userController.Getuser("clarson");
            var            expected       = "*****@*****.**";
            var            actual         = actionUser.Value.Email;

            Assert.Equal(expected, actual);
        }
コード例 #26
0
        public String Login(string username, string password)
        {
            var result = UserMethods.Login(username, password);

            if (result != null)
            {
                Session["User"] = result;
                user            = result;
            }
            return(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
コード例 #27
0
        public void QuadrupleTheIntReturnsQuadrupleTheInt()
        {
            // arrange
            var businessClass = new UserMethods();
            int x             = 4;

            // act
            int result = businessClass.QuadrupleTheInt(x);

            // assert
            Assert.Equal(16, result);
        }
コード例 #28
0
        public ActionResult ListUsers()
        {
            ViewBag.User = (User)Session["User"];
            User user     = (User)Session["User"];
            var  userList = UserMethods.GetUsersInDomain(user.UserID);

            ViewBag.ScheduleList = UserMethods.GetSchedule(user.UserID);
            if (userList != null)
            {
                ViewBag.UserList = userList;
            }
            return(View("List"));
        }
コード例 #29
0
        public String SendMessage(string uidreciever, string message)
        {
            User    user = (User)Session["User"];
            Message mes  = new Message();

            mes.senderid   = user.UserID;
            mes.recieverid = Guid.Parse(uidreciever);
            mes.message1   = message;
            mes.CreateDate = DateTime.Now;
            var result = UserMethods.SendMessage(mes);

            return(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
コード例 #30
0
ファイル: UserService.svc.cs プロジェクト: loyalkey/Loyal-Key
        public string AddUser(string identifier, string companyID)
        {
            UserMethods um = new UserMethods();

            try
            {
                int companyIDInt = Int32.Parse(companyID);
                return(um.AddUser(identifier, companyIDInt));
            }
            catch (Exception e)
            {
                return("bad");
            }
        }