public static Dictionary<String, Object> login(String username, String password)
        {
            Dictionary<String, Object> loginData = new Dictionary<string, object>();
            UserFacade userFac = new UserFacade();
            loginData = userFac.login(username, password);

            try
            {

            }
            catch (Exception e)
            {
                String t = e.ToString();
                String f = t;
            }

            //userFac.create("Hello");
            
            String Teee = "Fee";
            String test = username;
            String test2 = password;



            
            loginData.Add(test, Teee);
            return loginData;
        }
        public void systemHandler(Dictionary<String, Object> data)
        {


            // Retrive context from dictionary
            HttpContext context = (HttpContext)data["HttpResponse"];

            // Set type of expected string
            context.Response.ContentType = "text/html;charset=UTF-8";


            // Authenticate user to see if it has firstly logged in if not then 
            // Redirect that person
            if (context.Session["userId"] ==  null       &&
                context.Session["userFistName"] ==  null &&
                context.Session["userLastName"] == null)
            {
                context.Response.Redirect("", false);
                context.ApplicationInstance.CompleteRequest();
                return; 
            }

            // Dictionary to hold data to be returned
            Dictionary<String, Object> portalData = null;

            try
            {
                // Retrive Person Id
                Decimal personId = (Decimal)context.Session["userId"];

                // Let us get all the users in the ChatRoom
                userFacade = new UserFacade();
                portalData = userFacade.getAllUsersInChatRoom(personId);

                //String test = JsonConvert.SerializeObject(portalData);

                // Send Object Serialized
                context.Response.Write(JsonConvert.SerializeObject(portalData));

            }
            catch (Exception ex)
            {
                ex.ToString();
            }

        }
示例#3
0
        private int GetRowCount()
        {
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            UserFacade          userFacade          = new UserFacade(this.DataProvider);

            string[] usergroupList = userFacade.GetUserGroupCodeofUser1(GetUserCode());
            if (_documentFacade == null)
            {
                _documentFacade = new DocumentFacade(this.DataProvider);
            }
            return(this._documentFacade.QueryInDocuments1Count(FormatHelper.CleanString(this.txtInvdocnoQuery.Text.ToUpper()),
                                                               FormatHelper.CleanString(this.txtDocnameQuery.Text.ToUpper()), //Jarvis
                                                               FormatHelper.CleanString(this.drpDirNameQuery.SelectedValue),  //Jarvis
                                                               FormatHelper.CleanString(this.txtMemoQuery.Text.ToUpper()),    //Jatvis
                                                               FormatHelper.CleanString(this.drpDoctypeQuery.SelectedValue),
                                                               txtPickNoQuery.Text.Trim().ToUpper(), usergroupList
                                                               ));
        }
示例#4
0
        public async Task <ActionResult> Fight(Guid?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "User"));
            }

            var player1 = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            var player2 = await UserFacade.GetAsync(id.GetValueOrDefault());

            var model = new CombatModel()
            {
                Player1 = player1, Player2 = player2
            };

            return(View(model));
        }
        public async Task RegisterUser_Success()
        {
            var mockManager       = new FacadeMockManager();
            var unitOfWorkMock    = FacadeMockManager.ConfigureUowMock().Object;
            var userService       = CreateUserService(mockManager);
            var friendshipService = CreateFriendshipService(mockManager);
            var facade            = new UserFacade(unitOfWorkMock, userService, friendshipService);
            var guid = await facade.RegisterUser(new UserCreateDto
            {
                Email    = "*****@*****.**",
                Username = "******",
                Password = "******"
            });

            var expected = await userService.GetAsync(guid);

            Assert.AreEqual(expected.Id, guid);
        }
示例#6
0
        public void OrderBackBackTest()
        {
            /*
             * Работает переход в обратную сторону по всем шагам визарда
             */
            UserFacade.LoginUser();
            CartFacade.AddProduct("900219191");

            OrderFacade.ProceedStep1("630091");
            OrderFacade.ProceedStep2(DevliveryType.Shop);
            OrderFacade.ProceedStep3("John Doe");

            OrderFacade.BackToStep3();
            OrderFacade.BackToStep2();
            OrderFacade.BackToStep1();

            Assert.IsTrue(Selenium.GetValue("//input[@class='text'][@type='text']") == "630091");
        }
示例#7
0
        private void InitStorageList()
        {
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            UserFacade          userFacade          = new UserFacade(this.DataProvider);

            string[] usergroupList = userFacade.GetUserGroupCodeofUser(GetUserCode());//+TOSTORAGE
            this.drpStorageQuery.Items.Add(new ListItem("", ""));

            object[] parameters = systemSettingFacade.GetDistinctParaInParameterGroup(usergroupList);
            if (parameters != null)
            {
                foreach (Domain.BaseSetting.Parameter parameter in parameters)
                {
                    drpStorageQuery.Items.Add(new ListItem(parameter.ParameterDescription, parameter.ParameterCode));
                }
            }
            this.drpStorageQuery.SelectedIndex = 0;
        }
示例#8
0
        public async Task <ActionResult> Quest(Guid?id)
        {
            if (id == null || (await MiniLocationFacade.GetMiniLocationAsync(id.GetValueOrDefault())) == null)
            {
                return(RedirectToAction("Index"));
            }
            var inspect = new InspectMiniLocationDto
            {
                MiniLocationDto = await MiniLocationFacade.GetMiniLocationAsync(id.GetValueOrDefault())
            };

            inspect.QuestDto   = inspect.MiniLocationDto.Quest;
            inspect.MonsterDto = inspect.QuestDto.Monster;
            var userDto = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            inspect.CharacterDto = userDto.Character;
            return(View(inspect));
        }
示例#9
0
        public void Delete_ShouldNotDeleteWhenUserNotFound()
        {
            //arrange
            var userToBeDeleted = 4;

            var mockUserRepository = new Mock <IUserRepository>().Object;

            Mock.Get <IUserRepository>(mockUserRepository).Setup(r => r.Get(userToBeDeleted));

            var userFacade     = new UserFacade(mockUserRepository);
            var userController = new UserController(userFacade);

            //act
            var result = userController.Delete(userToBeDeleted) as OkNegotiatedContentResult <bool>;

            //assert
            Assert.Null(result);
        }
示例#10
0
        public void GetUser_ShouldNotReturnUser()
        {
            //arrange
            var userIdToBeQueried = 1000;

            var mockUserRepository = new Mock <IUserRepository>().Object;

            Mock.Get <IUserRepository>(mockUserRepository).Setup(r => r.Get(userIdToBeQueried));

            var userFacade     = new UserFacade(mockUserRepository);
            var userController = new UserController(userFacade);

            //act
            var result = userController.GetUser(userIdToBeQueried) as OkNegotiatedContentResult <UserDto>;

            //assert
            Assert.AreEqual(null, result);
        }
示例#11
0
        // GET: Home
        public async Task <ActionResult> Index()
        {
            var u = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            if (u.Character == null)
            {
                return(RedirectToAction("Create", "Character"));
            }
            var list = await UserFacade.GetAllAsync();

            var toShow = list.Where(a => a.Character != null && a.Score >= u.Score).OrderByDescending(a => a.Score).Take(9).ToList();

            if (!toShow.Contains(u))
            {
                toShow.Add(u);
            }
            return(View(toShow));
        }
示例#12
0
 private void loginWithFacebook()
 {
     try
     {
         LoginResult  loginResult  = Login.LoginWithFacebook();
         UserFacade   user         = new UserFacade(loginResult.LoggedInUser);
         DialogResult dialogResult = new MainForm(user).ShowDialog();
         Hide();
         if (dialogResult == DialogResult.Cancel)
         {
             Show();
         }
     }
     catch
     {
         MessageBox.Show("Something went wrong - please try again");
     }
 }
示例#13
0
        public async Task <ActionResult> Delete(int id, FormCollection collection)
        {
            try
            {
                bool success = await UserFacade.DeleteCorporationAsync(id);

                if (!success)
                {
                    return(View("~/Views/Home/GeneralExceptionView.cshtml"));
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("~/Views/Home/GeneralExceptionView.cshtml"));
            }
        }
示例#14
0
 public void TestInitialize()
 {
     //*firefoxchrome
     //*iexplore
     //*opera
     //*safari
     //*googlechrome
     Selenium = new SeleniumDecorator("localhost", 4444, @"*iexplore", "http://bookean-dev/");
     //_selenium = new DefaultSelenium("localhost", 4444, @"*firefoxJ:\Program Files\Mozilla Firefox\firefox.exe", "http://bookean-dev/");
     Selenium.Start();
     Selenium.SetTimeout("50000");
     ProductListFacade   = new ProductListFacade(Selenium);
     UserFacade          = new UserFacade(Selenium);
     CartFacade          = new CartFacade(Selenium);
     OrderFacade         = new OrderFacade(Selenium);
     SearchFacade        = new SearchFacade(Selenium);
     _verificationErrors = new StringBuilder();
 }
示例#15
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < presDates.Count; i++)
     {
         for (int j = 0; j < users.Length; j++)
         {
             Students_Groups[] stdgrp = UserFacade.GetGroupStudentID(users[j].ID);
             for (int l = 0; l < stdgrp.Length; l++)
             {
                 if (stdgrp[l].Active == true)
                 {
                     DependencyFacade.UpdatePresences(presDates[i], stdgrp[l].ID, dataGridView1[j, i].Value.ToString());
                 }
             }
         }
     }
     this.Hide();
 }
示例#16
0
        public void RemoveContactWithValidUserAndFriendIDsReturnNothing()
        {
            try
            {
                using (UserFacade facade = new UserFacade())
                {
                    Guid userId   = Guid.NewGuid();
                    Guid friendId = Guid.NewGuid();

                    facade.RemoveContact(userId, friendId);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to create user. Exception: {0}", ex.Message);
            }

            Assert.Pass();
        }
示例#17
0
 public void CreateUserWithNullObjectReturnUserException()
 {
     try
     {
         using (UserFacade facade = new UserFacade(mockConnect.Object))
         {
             IUser user = null;
             facade.CreateUser(user);
         }
     }
     catch (UserException)
     {
         Assert.Pass();
     }
     catch (Exception ex)
     {
         Assert.Fail("Unexpected exception escaped call to create user. Exception: {0}", ex.Message);
     }
 }
示例#18
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new UserDTO
                {
                    UserName = model.UserName,
                    Password = model.Password
                };

                var facade = new UserFacade();
                facade.Register(user);

                return(RedirectToAction("Index", "Home"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#19
0
        public JsonResult EditProfile(UserModel model)
        {
            bool successStatus = false;

            try
            {
                int uid = int.Parse(Request.Cookies["UserID"].Value);
                model.UserID = uid;
                int userid = new UserFacade().CreateOrModify(model);
                successStatus = userid > 0 ? true : false;
            }
            catch (Exception ex)
            {
                return(this.Json("{\"Error\": \"" + ex.Message + "\"}"));
            }
            string jsonResult = "{\"Success\": \"" + successStatus.ToString() + "\"}";

            return(this.Json(jsonResult));
        }
示例#20
0
        public async Task <ActionResult> MessageDetail(Guid?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Messages"));
            }

            var model = await UserFacade.MessageGetAsync(id.GetValueOrDefault());

            if (!model.IsRead)
            {
                var updated = new MessageEditDto()
                {
                    Id = model.Id, IsRead = true
                };
                await UserFacade.MessageEditAsync(updated);
            }
            return(View(model));
        }
示例#21
0
        public override string[] GetRolesForUser(string username)
        {
            var cacheKey = string.Format(CultureInfo.InvariantCulture, "{0}_role", username);

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((string[])HttpRuntime.Cache[cacheKey]);
            }

            string[] roles = new string[] { };
            using (IUserFacade userFacade = new UserFacade())
            {
                int?roleValue = userFacade.GetRoleByUser(username);
                roles = new string[] { roleValue.ConvertToString() };
                HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(_cacheTimeoutInMinute), Cache.NoSlidingExpiration);
            }

            return(roles);
        }
        public void systemHandler(Dictionary <String, Object> data)
        {
            // Retrive context from dictionary
            HttpContext context = (HttpContext)data["HttpResponse"];

            // Set type of expected string
            context.Response.ContentType = "text/html;charset=UTF-8";


            // Authenticate user to see if it has firstly logged in if not then
            // Redirect that person
            if (context.Session["userId"] == null &&
                context.Session["userFistName"] == null &&
                context.Session["userLastName"] == null)
            {
                context.Response.Redirect("", false);
                context.ApplicationInstance.CompleteRequest();
                return;
            }

            // Dictionary to hold data to be returned
            Dictionary <String, Object> portalData = null;

            try
            {
                // Retrive Person Id
                Decimal personId = (Decimal)context.Session["userId"];

                // Let us get all the users in the ChatRoom
                userFacade = new UserFacade();
                portalData = userFacade.getAllUsersInChatRoom(personId);

                //String test = JsonConvert.SerializeObject(portalData);

                // Send Object Serialized
                context.Response.Write(JsonConvert.SerializeObject(portalData));
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
示例#23
0
        public void RetrieveContactWithUserIdAsNinesReturnInvalidUserException()
        {
            var usrId = new Guid("99999999-9999-9999-9999-999999999999");
            IEnumerable <IUser> userfriends = null;
            List <IUser>        friends     = new List <IUser>();

            friends.Add(new User()
            {
                Name = "Jack Frost", ID = Guid.NewGuid()
            });
            friends.Add(new User()
            {
                Name = "Tom Ridder", ID = Guid.NewGuid()
            });
            friends.Add(new User()
            {
                Name = "Uni Daisy", ID = Guid.NewGuid()
            });
            friends.Add(new User()
            {
                Name = "Lisa Hunter", ID = Guid.NewGuid()
            });
            UserRepositoryMock <User> .ListOfUsers = friends;

            try
            {
                using (UserFacade facade = new UserFacade())
                {
                    userfriends = facade.RetrieveContacts(usrId);
                }
            }
            catch (InvalidUserIdException)
            {
                Assert.Pass();
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to retrieve contacts. Exception: {0}", ex.Message);
            }

            Assert.Fail("An InvalidUserIdException should have been thrown");
        }
示例#24
0
        public void RemoveContactWhenRepositoryExceptionHappensReturnException()
        {
            UserRepositoryMock <User> .ThrowException = true;
            try
            {
                using (UserFacade facade = new UserFacade())
                {
                    Guid userId   = Guid.NewGuid();
                    Guid friendId = Guid.NewGuid();

                    facade.RemoveContact(userId, friendId);
                }
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail("An Exception from the repository should have bubbled up.");
        }
        private async Task <ActionResult> AddReply(Guid postId, string username, string reply)
        {
            if (postId == Guid.Empty)
            {
                return(Index());
            }
            try
            {
                string url    = Request.UrlReferrer.AbsoluteUri;
                var    userId = (await UserFacade.GetUserByUsernameAsync(username)).Id;
                await PostFacade.AddReplyToPost(postId, userId, reply);

                return(Redirect(url));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Reply", e.Message);
                return(View());
            }
        }
示例#26
0
        protected void ucIList_InstanceRowDeleting(object sender, InstanceRowDeletingEventArgs e)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                UserFacade facade = new UserFacade(uow);
                IFacadeUpdateResult <UserData> result = facade.DeleteUser(e.Instance.Id);
                e.IsSuccessful = result.IsSuccessful;

                if (result.IsSuccessful)
                {
                    // Refresh whole list
                    CurrentInstances = facade.RetrieveAllUser();
                }
                else
                {
                    // Deal with Update result
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
        }
        public void ChangePasswordWithKey_GetChangedPassword()
        {
            //Arrange
            var accountFacade        = new AccountFacade(_keysRepository, _userRepository, _emailSender.Object, userSettings);
            var userFacade           = new UserFacade(_userRepository, _groupRepository, _eventRepository, _publisher.Object);
            var expectedPasswordHash = Credentials.FromRawData("someEmail", "newPassword").PasswordHash;
            var userId = accountFacade.RegUser("Alena", Credentials.FromRawData("email", "password"), true);

            var key = new Key("email", KeyAppointment.ChangePassword);

            _keysRepository.AddKey(key);

            //Act
            accountFacade.ChangePassword("newPassword", key.Value);
            var currentUser = userFacade.GetUser(userId);

            //Assert
            Assert.AreEqual(expectedPasswordHash, currentUser.Credentials.PasswordHash);
            Assert.AreEqual(true, key.Used);
        }
示例#28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserFacade    userFacade    = new UserFacade();
            PostFacade    postFacade    = new PostFacade();
            AlbumFacade   albumFacade   = new AlbumFacade();
            CommentFacade commentFacade = new CommentFacade();

            User    user    = userFacade.GetUsers();
            Posts   post    = postFacade.GetPosts();
            Albums  album   = albumFacade.GetAlbums();
            Comment comment = commentFacade.GetComments();

            lblUserName.Text     = user.Name;
            lblTitlePost.Text    = post.Title;
            lblBodyPost.Text     = post.Body;
            lblTitleAlbum.Text   = album.Title;
            lblNameComment.Text  = comment.Name;
            lblEmailComment.Text = comment.Email;
            lblBodyComment.Text  = comment.Body;
        }
示例#29
0
 public void UpdateUserWhenExceptionOccursInRepositoryReturnUserException()
 {
     UserRepositoryMock <User> .ThrowException = true;
     try
     {
         using (UserFacade facade = new UserFacade(mockConnect.Object))
         {
             IUser user = new User()
             {
                 Name = "Kevin Arnold", ID = Guid.NewGuid()
             };
             facade.UpdateUser(user);
         }
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail("An Exception should have been generated");
 }
示例#30
0
        public void FindUserUsingNonExistingUserIdReturnNull()
        {
            var   usrId = Guid.NewGuid();
            IUser user  = new User();

            UserRepositoryMock <User> .ListOfUsers = new List <IUser>();

            try
            {
                using (UserFacade facade = new UserFacade(mockConnect.Object))
                {
                    user = facade.FindUser(usrId);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception escaped call to find a user. Exception: {0}", ex.Message);
            }
            Assert.IsTrue(user == null);
        }
示例#31
0
        public void FindUserWhenExceptionHappensReturnNull()
        {
            var   usrId = Guid.NewGuid();
            IUser user  = null;

            UserRepositoryMock <User> .ThrowException = true;

            try
            {
                using (UserFacade facade = new UserFacade(mockConnect.Object))
                {
                    user = facade.FindUser(usrId);
                }
            }
            catch (Exception)
            {
                Assert.Pass();
            }
            Assert.Fail("An Exception from the repository should have bubbled up.");
        }
示例#32
0
        public void AddContactWhenExceptionHappensReturnNothing()
        {
            UserRepositoryMock <User> .ThrowException = true;
            try
            {
                using (UserFacade facade = new UserFacade(mockConnect.Object))
                {
                    Guid userId   = Guid.NewGuid();
                    Guid friendId = Guid.NewGuid();

                    facade.AddContact(userId, friendId);
                }
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail("An Exception should have bubbled up from the Repository.");
        }
        public void systemHandler(Dictionary<String, Object> data)
        {
    
            // Retrive context from dictionary
            HttpContext context = (HttpContext)data["HttpResponse"];

            // Set type of expected string
            context.Response.ContentType = "text/html;charset=UTF-8";

            // Initialize Values
            String username = "";
            String password = "";

            // Get parameters from url
            username = context.Request.Params["username"];
            password = context.Request.Params["password"];

            Dictionary<String, Object> portalData = null;
            // Send values to be evaluated
                try
                {
                    // Double check just in the very remote case the front end did not handle well the input for these fields
                    // before sending it remotely accross the web to see if it exists
                    if (username == "undefined"  ||  password == "undefined" ||
                        username == null         ||  password == null        ||
                        username == ""           ||  password == "")
                    {
                        // So if the username field or password is missing when they first log in we will redirect and terminate 
                        // the execution of the code until the fields are completed properly
                        // Since I am using the $locationProvider on the front end I don't need to specify the root since it will handle
                        // all for me otherwise when it makes a 404 no found it will return the whole index html page 
                        context.Response.Redirect("", false);
                        context.ApplicationInstance.CompleteRequest();
                        return;                   
                       
                    }

                    // Communicate to remote function to get all info about person trying to log-in
                    // Outside of classed is mapped to this -> private UserFacadeRemote personFacade;
                    // In java the framework will handle the instantiation and removal of objects but
                    // since I don't how to set it up in asp.net I had to do it this way

                    // Instance of userFacade
                    userFacade = new UserFacade();
                    // Execute Remote function call to evaluate the username and password
                    portalData = userFacade.login(username, password);

                    // Evaluate if there is a user with that usename and password
                    if (portalData == null)
                    {
                        // Redirect with error, tipically its documented to use true
                        // for the second parameter but that causes to through an exceptio
                        // which is aborting thread which does the trick but its definetely 
                        // poor login so I use false which does the redirect but won't terminate the execution of the code
                        // the following line will terminate the request and I use return to not allow any further code to be executed
                        // Since I am using the $locationProvider on the front end I don't need to specify the root since it will handle
                        // all for me otherwise when it makes a 404 no found it will return the whole index html page 
                        context.Response.Redirect("", false);
                        context.ApplicationInstance.CompleteRequest();
                        return;
                    }

                    // Up to this point user should exist so lets Store User Locally
                    // By retriving the user profile 
                    if (portalData.ContainsKey("UserProfile")){
                        userLogged = (UserSerializable)portalData["UserProfile"];
                    }
                    else {
                        // Redirect with error
                        context.Response.Redirect("", false);
                        context.ApplicationInstance.CompleteRequest();
                        return; 
                    }
                       
                    // and saving authentication token on session
                    context.Session["userId"] = userLogged.getPersonId();
                    context.Session["userFistName"] = userLogged.getFirstName();
                    context.Session["userLastName"] = userLogged.getLastName();

                    // Return Serialized object to Http Request back in AngularJS
                    //JavaScriptSerializer js = new JavaScriptSerializer();
                    //String testJSSerializer = js.Serialize(portalData);
                    String testSerialization = JsonConvert.SerializeObject(portalData);

                    // Send Object Serialized
                    context.Response.Write(JsonConvert.SerializeObject(portalData));

                  





                }
                catch (Exception ex)
                {
                    String debug = ex.ToString();
                    String de = debug;
                    
                }
        }