示例#1
0
 public void UpdateUser([FromBody] UserDetailModel value)
 {
     try
     {
         _repository.Update(value);
     }
     catch (Exception e)
     {
     }
 }
示例#2
0
        public UserDetailModel Registration(UserDetailModel model)
        {
            var salt = GetSalt();
            var hash = GetHashString(model.password, salt);

            model.salt     = salt;
            model.password = hash;

            return(_userRepository.Add(model));
        }
示例#3
0
        public async Task <ActionResult> Index()
        {
            var token = await GetAccessToken();

            // wait for model class 'Models/UserDetailModel' to be populated....
            var user = await UserDetailModel.GetUserDetail("me", token.AccessToken);

            // pass model data to 'Views/User/Index'
            return(View(user));
        }
        public async Task <ActionResult> PostMethod1([FromBody] UserDetailModel user)
        {
            Boolean valid = true;

            //List<UserDetailModel> userdetails = await Get();
            // validating the user cred
            valid = await ValidateUser(user);

            return(Json(valid));
        }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        // Default UserStore constructor uses the default connection string named: DefaultConnection
        var userStore = new UserStore<IdentityUser>();

        //Set ConnectionString to GarageConnectionString
        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.ConnectionStrings["GarageConnectionString"].ConnectionString;
        var manager = new UserManager<IdentityUser>(userStore);

        //Create new user and try to store in DB.
        var user = new IdentityUser { UserName = txtUserName.Text };

        if (txtPassword.Text == txtConfirmPassword.Text)
        {
            try
            {
                IdentityResult result = manager.Create(user, txtPassword.Text);
                if (result.Succeeded)
                {
                    UserDetail userDetail = new UserDetail
                    {
                        Address = txtAddress.Text,
                        FirstName = txtFirstName.Text,
                        LastName = txtLastName.Text,
                        Guid = user.Id,
                        PostalCode = Convert.ToInt32(txtPostalCode.Text)
                    };

                    UserDetailModel model = new UserDetailModel();
                    model.InsertUserDetail(userDetail);

                    //Store user in DB
                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
                    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    //If succeedeed, log in the new user and set a cookie and redirect to homepage
                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }
                else
                {
                    litStatusMessage.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                litStatusMessage.Text = ex.ToString();
            }
        }
        else
        {
            litStatusMessage.Text = "Passwords must match!";
        }
    }
示例#6
0
        public void RemoveUser_WithValidData_RemovesUserFromTeam()
        {
            //Arrange
            var sut        = CreateSUT();
            var modelUser1 = new UserDetailModel()
            {
                Username = "******",
                Name     = "Sergey Lavrov",
                Password = "******",
                Gender   = Gender.Male,
                Email    = "*****@*****.**"
            };
            var modelUser2 = new UserDetailModel
            {
                Username = "******",
                Name     = "Dmitry Medvedev",
                Password = "******",
                Gender   = Gender.Male,
                Email    = "*****@*****.**",
                Status   = Status.DoNotDisturb
            };

            var teamModel = new TeamDetailModel()
            {
                Name        = "IFJ projects",
                Description = "This team is dedicated for users, " +
                              "who are working on IFJ projects."
            };

            var createdUserModel1 = sut.Create(modelUser1);
            var createdUserModel2 = sut.Create(modelUser2);
            var createdTeamModel  = sut.Create(teamModel);
            var teamEntity        = _mapper.MapTeamToEntity(createdTeamModel);

            try
            {
                //Act
                sut.AddUserToTeam(createdUserModel1, createdTeamModel.Id);
                sut.AddUserToTeam(createdUserModel2, createdTeamModel.Id);
                sut.GetAllUsersInTeam(createdTeamModel.Id);
                sut.RemoveUserFromTeam(createdUserModel1, createdTeamModel.Id);

                //Assert
                Assert.Equal(0, teamEntity.UserInTeam.Count);
            }
            finally
            {
                //Teardown
                if (createdTeamModel != null)
                {
                    sut.DeleteTeam(createdTeamModel.Id);
                }
            }
        }
示例#7
0
        public UserDetailModel Create(UserDetailModel user)
        {
            using (var dbContext = _dbContextFactory.CreateDbContext())
            {
                var entity = _mapper.MapUserToEntity(user);
                dbContext.Users.Add(entity);
                dbContext.SaveChanges();

                return(_mapper.MapUserDetailModelFromEntity(entity));
            }
        }
示例#8
0
        public virtual ActionResult Detail(int userId)
        {
            UserDetailModel selectedUser = _userService.GetUserDetail(userId);


            AvatarImage.DefaultPath = Url.Content("~/Content/Images/user.gif");
            AvatarImage.BasePath    = Url.Content("~/Content/avatars/");
            selectedUser.AvatarPath = AvatarImage.GetAvatarImage(selectedUser.UserName);

            return(PartialView(MVC.Admin.User.Views._Detail, selectedUser));
        }
示例#9
0
 public static UserListModel DetailToListModel(UserDetailModel userDetailModel)
 {
     return(new UserListModel
     {
         Id = userDetailModel.Id,
         Email = userDetailModel.Email,
         Name = userDetailModel.Name,
         Password = userDetailModel.Password,
         LastLoginTime = userDetailModel.LastLoginTime
     });
 }
示例#10
0
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            string sUsername = CreateUserWizard1.UserName;
            string sEmail    = CreateUserWizard1.Email;
            string sName     = CreateUserWizard1.Answer;
            string sContact  = CreateUserWizard1.Question;

            UserDetailModel.AddNewUser(sUsername, sEmail, sName, sContact);
            Response.Write("<script LANGUAGE='JavaScript' >alert('User registered successfully')</script>");
            Response.Redirect("~/Login.aspx");
        }
示例#11
0
        public async Task <IActionResult> Post([FromBody] UserDetailModel model)
        {
            Log.Information("api/User/Post");
            var userDetail = Mapper.Map <UserDetail>(model);

            userDetail.UserName = User.Identity.Name;

            var result = await _userService.SaveUserDetails(userDetail);

            return(this.GetResult(result));
        }
        public async Task <bool> SaveUserIntro(UserDetailModel detailModel)
        {
            var result = await _userDetailRepository.UpdateAboutIntro(detailModel.ProfileAddress,
                                                                      new UserDetail
            {
                UserId = UserContext.Current.UserId,
                About  = detailModel.About
            });

            return(result);
        }
        private ObservableCollection <UserDetailModel> ListToObservable(List <UserDetail> list)
        {
            var result = new ObservableCollection <UserDetailModel>();

            foreach (var user in list)
            {
                UserDetailModel userModel = new UserDetailModel(user);
                result.Add(userModel);
            }

            return(result);
        }
 public bool Update(UserDetailModel model)
 {
     try
     {
         UserDetail entity = new UserDetail();
         return(entity.Update(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void InsertStepSatus(UserDetailModel objobjUserDetailModel)
 {
     try
     {
         DLDocumentResponse objDLDocumentResponse = new DLDocumentResponse();
         objDLDocumentResponse.InsertStepSatus(objobjUserDetailModel);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task InsertUserAsync(UserDetailModel user)
        {
            string URL = URLbase + "/InsertUser";

            using (var httpClient = new HttpClient())
            {
                StringContent       content  = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");
                HttpResponseMessage response = await httpClient.PostAsync(URL, content);

                string apiResponse = await response.Content.ReadAsStringAsync();
            }
        }
示例#17
0
        public void Add_Remove_Post_TeamModel_Test()
        {
            var teamOne = new TeamDetailModel
            {
                Name = "ICS Team",
            };

            var user = new UserDetailModel
            {
                Name     = "Brisk",
                Email    = "*****@*****.**",
                Password = "******",
            };


            var postOne = new PostDetailModel
            {
                Title   = "Post v tymu",
                Content = "Jeste neni konec",
            };

            var postTwo = new PostDetailModel
            {
                Title   = "Post v tymu",
                Content = "Uz je konec",
            };

            var userModel    = _userRepository.Create(user);
            var postOneModel = _postRepository.Create(postOne, userModel);
            var postTwoModel = _postRepository.Create(postTwo, userModel);

            var teamModel = _teamRepository.Create(teamOne);


            Assert.NotNull(teamModel);
            Assert.Equal(teamOne.Name, teamModel.Name);

            teamModel = _teamRepository.AddPost(teamModel, postOneModel);

            Assert.Single(teamModel.Posts);

            teamModel = _teamRepository.AddPost(teamModel, postTwoModel);

            Assert.Equal(2, teamModel.Posts.Count);

            teamModel = _teamRepository.RemovePost(teamModel, postOneModel);

            Assert.Single(teamModel.Posts);

            //Teardown
            _userRepository.Delete(userModel.Id);
            _teamRepository.Delete(teamModel.Id);
        }
示例#18
0
        public ActionResult Resume_Read(DataSourceRequest request)
        {
            ResumeSearchFilter filter = Session[typeof(ResumeSearchFilter).FullName + "Resume_Read_Search"] as ResumeSearchFilter;

            if (filter == null)
            {
                filter = new ResumeSearchFilter();
            }
            List <UserDetailModel> returnObjs = UserDetailModel.SearchResumes(request.Page, request.PageSize, filter);

            return(Json(Helper.ToUIDataSourceResult <UserDetailModel>(false, returnObjs, request, returnObjs.Count()), JsonRequestBehavior.AllowGet));
        }
        public MessageModel InsertSingleEntity(UserDetailModel model)
        {
            Func <IEntityContext, string> operation = delegate(IEntityContext context)
            {
                //model.UserBase = null;
                context.UserDetail.Add(model);
                context.SaveChanges();
                return(string.Empty);
            };

            return(base.DbOperation(operation));
        }
示例#20
0
 public ActionResult BorrarUsuario(int?id)
 {
     if (id.HasValue)
     {
         userModel = MapperConfigurationCentral <UserDetailDto, UserDetailModel> .MapEntity(userDetailBusiness.GetUserById(id.Value), SpecificationMapper.SpecificationMapper.UserDetailDtoToModel);
     }
     else
     {
         return(RedirectToAction("Usuarios"));
     }
     return(View(userModel));
 }
示例#21
0
 public UserDetailModel Save(UserDetailModel model)
 {
     if (model.Id == Guid.Empty)
     {
         return(repository.Add(model));
     }
     else
     {
         repository.Update(model);
         return(model);
     }
 }
        public bool IsTheLastItem(object item)
        {
            bool            result   = false;
            UserDetailModel userItem = item as UserDetailModel;

            if (userItem != null)
            {
                result = ListOfEmployees.IndexOf(userItem) == ListOfEmployees.Count - 1;
            }

            return(result);
        }
示例#23
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        var userStore = new UserStore <IdentityUser>();

        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.ConnectionStrings["GarageConnectionString"].ConnectionString;
        var manager = new UserManager <IdentityUser>(userStore);

        var user = new IdentityUser {
            UserName = txtUserName.Text
        };

        if (txtPassword.Text == txtConfirmPassword.Text)
        {
            try
            {
                IdentityResult result = manager.Create(user, txtPassword.Text);
                if (result.Succeeded)
                {
                    UserDetail userDetail = new UserDetail
                    {
                        Address    = txtAddress.Text,
                        FirstName  = txtFirstName.Text,
                        LastName   = txtLastName.Text,
                        Guid       = user.Id,
                        PostalCode = Convert.ToInt32(txtPostalCode.Text)
                    };

                    UserDetailModel model = new UserDetailModel();
                    model.InsertUserDetail(userDetail);

                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
                    var userIdentity          = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }
                else
                {
                    litStatusMessage.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                litStatusMessage.Text = ex.ToString();
            }
        }
        else
        {
            litStatusMessage.Text = "Las Contraseñas deben coincidir!";
        }
    }
        public UserDetailModel Create(UserDetailModel user)
        {
            using (var dbContext = _fitterDbContext.CreateDbContext())
            {
                var passwordHasher = new PasswordHasher(user.Password);
                user.Password = passwordHasher.GetHashedPassword();

                var entity = _mapper.MapUserToEntity(user);
                dbContext.Users.Add(entity);
                dbContext.SaveChanges();
                return(_mapper.MapUserDetailModelFromEntity(entity));
            }
        }
        private async Task SetClaims(UserDetailModel userRecord, string guest = "")
        {
            var claimIdentity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);

            claimIdentity.AddClaim(new Claim(ClaimTypes.Sid, userRecord.Id.ToString()));
            claimIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userRecord.Id.ToString()));
            claimIdentity.AddClaim(new Claim(ClaimTypes.Email, userRecord.EmailId == null ? string.Empty : userRecord.EmailId));
            claimIdentity.AddClaim(new Claim(ClaimTypes.Role, Enums.RoleType.User.ToString()));
            claimIdentity.AddClaim(new Claim(ClaimTypes.Name, (userRecord.FirstName + " " + userRecord.LastName).Trim()));
            claimIdentity.AddClaim(new Claim(ClaimTypes.Actor, guest));

            await this.HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimIdentity));
        }
示例#26
0
        public UserDetailModel Login(UserDetailModel model)
        {
            var user = _userRepository.GetByEmail(model.email);

            if (user == null)
            {
                return(null);
            }

            var hash = GetHashString(model.password, user.salt);

            return(hash == user.password ? user : null);
        }
示例#27
0
        public UserDetailModel Add(UserDetailModel detail)
        {
            using (var teamCommunicationDbContext = dbContextFactory.CreateDbContext())
            {
                var user = UserMapper.MapUserDetailModelToEntity(detail);
                user.Id = Guid.NewGuid();

                teamCommunicationDbContext.Users.Add(user);
                teamCommunicationDbContext.SaveChanges();

                return(UserMapper.MapUserEntityToDetailModel(user));
            }
        }
示例#28
0
        public void RemoveUserFromTeam(UserDetailModel user, Guid teamId)
        {
            using (var dbContext = _dbContextFactory.CreateDbContext())
            {
                var entity = dbContext
                             .UserTeams
                             .Where(u => u.UserId == user.Id)
                             .First(t => t.TeamId == teamId);

                dbContext.UserTeams.Remove(entity);
                dbContext.SaveChanges();
            }
        }
示例#29
0
 public static User MapUserDetailModelToEntity(UserDetailModel model)
 {
     return(new User
     {
         Id = model.Id,
         email = model.email,
         firstName = model.firstName,
         lastName = model.lastName,
         nickname = model.nickname,
         password = model.password,
         salt = model.salt
     });
 }
        public UserDetailModel UserDetailMtd(string username)
        {
            string clientcode = Convert.ToString(ConfigurationManager.AppSettings["ClientCode"]).Trim().ToUpper();

            //string connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;

            string connectionString = "";

            if (clientcode == "ABP")
            {
                connectionString = ConfigurationManager.ConnectionStrings["FintrakDB2ndConnection"].ConnectionString;
            }
            else
            {
                connectionString = ConfigurationManager.ConnectionStrings["FintrakDBConnection"].ConnectionString;
            }

            var pts = new UserDetailModel();

            using (var con = new SqlConnection(connectionString))
            {
                var cmd = new SqlCommand("mpr_get_user_details", con);
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandTimeout = 0;

                cmd.Parameters.Add(new SqlParameter
                {
                    ParameterName = "UserName",
                    Value         = username,
                });

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    //pts.loginID = reader["LoginId"] != DBNull.Value ? reader["LoginId"].ToString() : "null";
                    //pts.MISCode = reader["MisCode"] != DBNull.Value ? reader["MisCode"].ToString() : "";
                    //pts.MISLevel = reader["MisLevel"] != DBNull.Value ? reader["MisLevel"].ToString() : "";
                    //pts.MISName = reader["MisName"] != DBNull.Value ? reader["MisName"].ToString() : "";

                    System.Web.HttpContext.Current.Session["session_loggedinID"]       = reader["LoginId"] != DBNull.Value ? reader["LoginId"].ToString() : "null";
                    System.Web.HttpContext.Current.Session["session_loggedinmiscode"]  = reader["MisCode"] != DBNull.Value ? reader["MisCode"].ToString() : "";
                    System.Web.HttpContext.Current.Session["session_loggedinmislevel"] = reader["MisLevel"] != DBNull.Value ? reader["MisLevel"].ToString() : "";
                    System.Web.HttpContext.Current.Session["session_loggedinmisname"]  = reader["MisName"] != DBNull.Value ? reader["MisName"].ToString() : "";
                }
                con.Close();
            }
            return(pts);
        }
示例#31
0
        public void GetUserLastPostTest()
        {
            var userRepository = new UserRepository(new InMemoryDbContextFactory());
            var author         = new UserDetailModel();

            var dbAuthor = userRepository.Insert(author);

            var postFirst = new PostDetailModel()
            {
                Title     = "First post",
                Comments  = new List <CommentDetailModel>(),
                Author    = author,
                Timestamp = new DateTime(2019, 4, 4),
                Content   = "Tak toto budem testovat"
            };

            var postSecond = new PostDetailModel()
            {
                Title     = "Second post",
                Comments  = new List <CommentDetailModel>(),
                Author    = author,
                Timestamp = new DateTime(2019, 4, 5),
                Content   = "A toto taky budem testovat"
            };


            var postLast = new PostDetailModel()
            {
                Title     = "Last post",
                Comments  = new List <CommentDetailModel>(),
                Author    = author,
                Timestamp = new DateTime(2019, 4, 6),
                Content   = "Toto uz nebudem testovat"
            };

            var postFirstDb  = _posRepository.Insert(postFirst);
            var postSecondDb = _posRepository.Insert(postSecond);
            var postDetail   = _posRepository.Insert(postLast);

            var postsDatabase = _posRepository.GetUserLastPosts(author.Id, 2);

            Assert.Equal(2, postsDatabase.Count());
            Assert.Equal(postSecond.Title, postsDatabase.Last().Title);
            Assert.Equal(postSecond.Content, postsDatabase.Last().Content);
            Assert.Equal(postLast.Title, postsDatabase.First().Title);
            Assert.Equal(postLast.Content, postsDatabase.First().Content);

            _posRepository.Remove(postFirstDb.Id);
            _posRepository.Remove(postSecondDb.Id);
            _posRepository.Remove(postDetail.Id);
        }
 public ActionResult Delete(UserDetailModel model)
 {
     if (model != null && !String.IsNullOrEmpty(model.Username))
     {
         if (!model.Username.Equals(User.Id(), StringComparison.OrdinalIgnoreCase))
         {
             MembershipService.DeleteUser(model.Username);
             TempData["DeleteSuccess"] = true;
         }
         else
         {
             TempData["DeleteSuccess"] = false;
         }
     }
     return RedirectToAction("Index");
 }
 public ActionResult Detail(string id)
 {
     if (!String.IsNullOrEmpty(id))
     {
         UserModel user = MembershipService.GetUser(id);
         if (user != null)
         {
             var model = new UserDetailModel
             {
                 Username = user.Name,
                 Name = user.GivenName,
                 Surname = user.Surname,
                 Email = user.Email,
                 Roles = RoleProvider.GetRolesForUser(user.Name),
                 IsReadOnly = MembershipService.IsReadOnly()
             };
             return View(model);
         }
     }
     return View();
 }