public IHttpActionResult Login([FromUri] string tz, string passw) //לאן חוזר ההחזרה באנגולר ומה עושים עם זה { // List<DAL.StatusesToUsers_Tbl> listStatus = UsersBLL.Login(tz); //if (listStatus.Count > 0) // { UserDetailsDTO userDetailsDTO = new UserDetailsDTO(); userDetailsDTO = UsersBLL.GetUserByTZAndPw(tz, passw); try { if (userDetailsDTO.StatusList.Count() > 0) { HttpCookie userTZCookie = new HttpCookie("UserTZ", userDetailsDTO.tz); return(Ok(userDetailsDTO));//listStatus } } catch (Exception) { return(BadRequest("Sory, Your password or tz is incorrect")); } //אין הרשאות גישה רשום אבל לא מאושר return(BadRequest("you are not alloud to log in yet ")); //} //return Ok(Json<List<DAL.StatusesToUsers_Tbl>>(listStatus)); }
public static UserDetailsDTO GetStatusNamesForUser(Users_Tbl user) { using (BeitHamoreProjectEntities db = new BeitHamoreProjectEntities()) { if (user != null) { var tt = new UserDetailsDTO { tz = user.tz, userId = user.userId, city = user.city, emailAddress = user.emailAddress, firstName = user.firstName, houseNumber = user.houseNumber, lastName = user.lastName, phone = user.phone, passwordSHA256 = user.passwordSHA256, street = user.street, StatusList = db.StatusesToUsers_Tbl.Include(st => st.Status_Tbl).Where(st => st.userId == user.userId && st.isApproved.Value == 1).ToList().Select(sp => StatusDTOConverssions.GetStatus(sp.Status_Tbl)).ToList() }; return(tt); } return(null); } }
public IHttpActionResult PutUpdateUser(UserDetailsDTO userdetails) { User user = new User(); _tenantRepository.Update(user); return(Ok("Update Successfull")); }
public void Update(UserDetailsDTO user) { var p = _mapper.Map <UserDetails>(user); _db.Users.Update(p); _db.Save(); }
public UserDetailsDTO GetByID([FromRoute] int id) { var result = _userManager.GetUserDetailsById(id); UserDetailsDTO userDetailsDTO = _mapper.Map <UserDetailsDTO>(result); return(userDetailsDTO); }
public string Put(UserDetailsDTO userDetailsDTO) { try { userDetailsDTO.UdDob = Convert.ToDateTime(userDetailsDTO.DateOfBirth); } catch { return("Incorrect DOB"); } if (userDetailsDTO.UdName == null || userDetailsDTO.UdName == "") { return("Please enter name"); } if (userDetailsDTO.UdSex == null || userDetailsDTO.UdSex <= 0) { return("Please select gender"); } userDetailsDTO.UdIsDeleted = false; UserDetails userDetails = _mapper.Map <UserDetails>(userDetailsDTO); if (_userManager.UpdateUser(userDetails)) { return("Data updated"); } return("Data did not updated. Please try again."); }
public List<dynamic> GetUserdetails(UserDetailsDTO user) { List<dynamic> objDynamic = new List<dynamic>(); String insertProcedure = "[Get_UserMaster]"; Dictionary<string, string> input_parameters = new Dictionary<string, string>(); input_parameters.Add("@UserId", 1 + "#bigint#" + user.UserId); input_parameters.Add("@Type", 1 + "#int#" + user.Type); DataSet ds = obj.SelectSql(insertProcedure, input_parameters); var myEnumerable = ds.Tables[0].AsEnumerable(); List<UserDetailsDTO> ud = (from item in myEnumerable select new UserDetailsDTO { UserId = item.Field<Int64>("UserId"), UserName = item.Field<String>("UserName"), Password = item.Field<String>("Password"), FirstName = item.Field<String>("FirstName"), LastName = item.Field<String>("LastName"), MobileNumber = item.Field<Int64>("MobileNumber"), EmailId = item.Field<String>("EmailId"), NoOfAttempts = item.Field<int>("NoOfAttempts"), IsLoginActive = item.Field<Boolean>("IsLoginActive"), }).ToList(); objDynamic.Add(ud); return objDynamic; }
/// <summary> /// Maps user details DTO to user details view model. /// </summary> public static UserDetailsViewModel ToViewModel(this UserDetailsDTO item) { if (item == null) { return(null); } return(new UserDetailsViewModel { RealName = item.RealName, UserName = item.UserName, Avatar = item.Avatar != null ? $"/data/avatars/{item.UserName}/{item.Avatar}" : string.IsNullOrEmpty(item.Gender) || item.Gender == "Male" ? "/images/defaults/def-male-logo.png" : "/images/defaults/def-female-logo.png", About = item.About != null ? item.About : string.Empty, Date = item.Date.ToString("MMMM dd, yyyy"), Confirmed = item.Confirmed, Followed = item.Followed, Gender = item.Gender, WebSite = item.WebSite, Blocked = item.Blocked, PrivateAccount = item.PrivateAccount, IBlocked = item.IBlocked, Followings = item.Followings.ToViewModels(), Followers = item.Followers.ToViewModels(), Mutuals = item.Mutuals?.ToViewModels() }); }
public ActionResult ContactInformation() { if (Session["UserId"] != null) { UserDetailsDTO Userdata = UserInfoService.GetUserContactInformation(Convert.ToInt32(Session["UserId"].ToString())); ContactInformation Info = new ContactInformation() { //CountryCodes = Convert.ToInt32(Userdata.CountryCode), //Mobile = Userdata.PhoneNumber, //AlternateEmail = Userdata.AlternateEmailId, //CountryId = Userdata.CountryId.Value, ////States = StatecitydistrictService.GetAllStates(), //PresentAddress = Userdata.Address, //PermanentAddress = Userdata.PermanentAddress, //PermenantDistrictId = Convert.ToInt32(Userdata.DistrictId), ////PermanentCityId = Userdata.HomeCityId, ////CityId = Userdata.LivesInCityId, //StateId = Convert.ToInt32(Userdata.StateId), //PermanentStateId = Convert.ToInt32(Userdata.StateId), //PermanentCountryid = Userdata.PermanentCountryId.Value Countrys = GenericMethods.GetAllCountries(), }; return(View(Info)); } return(RedirectToAction("Login", "Account", new { area = "" })); }
public async Task <ActionResult <UserDetailsDTO> > Post(UserDetailsDTO userDetailsDTO) { try { var userDetails = mapper.Map <UserDetails>(userDetailsDTO); userDetails.CreateDate = DateTime.UtcNow; userDetails.TimeStamp = DateTime.UtcNow; userDetails.StatusId = (int)UserStatusEnum.New; var validation = ValidatePost(userDetails); if (validation == null) { context.Add(userDetails); await context.SaveChangesAsync(); return(Ok(mapper.Map <UserDetailsDTO>(userDetails))); } else { return(BadRequest(validation)); } } catch (Exception ex) { return(BadRequest(new ErrorManager(ex.GetBaseException()))); } }
public bool SaveUser(UserDetails userDetailsRequest) { UserDetails response = new UserDetails(); var userDetails = new UserDetailsDTO(); var cmd = new SqlCommand(); using (SqlConnection con = new SqlConnection(CS)) { if (userDetailsRequest.ID != 0) { cmd = new SqlCommand("Update [dbo].[USER] SET NAME=@name,EMAIL=@email,MOBILENO=@mobileno,USERROLEID=@userroleid,USERSTATUSID=@userstatusid where ID=@id", con); cmd.Parameters.AddWithValue("@id", userDetailsRequest.ID); } else { cmd = new SqlCommand("Insert into [dbo].[USER](NAME,EMAIL,MOBILENO,USERROLEID,USERSTATUSID) VALUES(@name,@email,@mobileno,@userroleid,@userstatusid)", con); } cmd.CommandType = CommandType.Text; con.Open(); cmd.Parameters.AddWithValue("@name", userDetailsRequest.NAME); cmd.Parameters.AddWithValue("@email", userDetailsRequest.EMAIL); cmd.Parameters.AddWithValue("@mobileno", userDetailsRequest.MOBILENO); cmd.Parameters.AddWithValue("@userroleid", userDetailsRequest.USERROLE); cmd.Parameters.AddWithValue("@userstatusid", userDetailsRequest.USERSTATUS); SqlDataReader rdr = cmd.ExecuteReader(); } return(true); }
public UserDetailsResponseDTO GetUserById(int userId) { var userDetailsResponse = new UserDetailsResponseDTO(); userDetailsResponse.UserDetails = new List <UserDetailsDTO>(); using (SqlConnection con = new SqlConnection(CS)) { var cmd = new SqlCommand("Select * from [dbo].[USER] u where u.id = @userId", con); cmd.Parameters.AddWithValue("@userId", userId); cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var userDetails = new UserDetailsDTO(); userDetails.Name = rdr["NAME"].ToString(); userDetails.Email = rdr["EMAIL"].ToString(); userDetails.MobileNo = Convert.ToInt32(rdr["MOBILENO"]); userDetails.UserRole = rdr["USERROLEID"].ToString(); userDetails.UserStatus = rdr["USERSTATUSID"].ToString(); userDetailsResponse.UserDetails.Add(userDetails); } return(userDetailsResponse); } }
public UserDetailsDTO GetUserContactInformation(int id) { try { using (var context = _dbContextFactory.CreateConnection()) { UserDetailsDTO data = (from a in context.UserDetails join b in context.Cities on a.HomeCityId equals b.Id join c in context.States on b.Stateid equals c.Id join d in context.Countries on c.CountryId equals d.Id join e in context.Cities on a.LivesInCityId equals e.Id join f in context.States on e.Stateid equals f.Id join g in context.Countries on f.CountryId equals g.Id join h in context.Districts on c.Id equals h.StateId where a.Id == id select new UserDetailsDTO { HomePhoneNumber = a.HomePhoneNumber, PresentCity = a.PresentCity, PermanentCity = a.PermanentCity, Permanentdistid = d.Id, PresentDistid = h.Id, PermanentCountryId = g.Id, PresentStateid = c.Id, PermanentStateid = f.Id, PermenantCityId = a.LivesInCityId, PresentCityid = a.HomeCityId, CountryId = d.Id, CountryCode = a.CountryCode, AlternateEmailId = a.AlternateEmailId, PhoneNumber = a.PhoneNumber, HomeCityId = a.HomeCityId, LivesInCityId = a.LivesInCityId, Address = a.Address, PermanentAddress = a.PermanentAddress, StateId = c.Id, DistrictId = b.DisctirctId }).First(); return(data); } } catch (Exception ex) { _Logger.Error(ex.Message, ex); throw ex; } }
public ActionResult UpdateContactDetails() { if (Session["UserId"] != null) { UserDetailsDTO Userdata = UserInfoService.GetUserContactInformation(Convert.ToInt32(Session["UserId"].ToString())); ContactInformation Info = new ContactInformation() { PresentAddress = Userdata.PermanentAddress, PermanentAddress = Userdata.Address, Countrys = GenericMethods.GetAllCountries(), CountryId = Userdata.CountryId.Value, PermanentCountryid = Userdata.PermanentCountryId.Value, Mobile = Userdata.PhoneNumber, StateId = Convert.ToInt32(Userdata.StateId), PermanentStateId = Convert.ToInt32(Userdata.StateId), Districtid = Userdata.PresentDistid.Value, PermenantDistrictId = Userdata.Permanentdistid, AlternateEmail = Userdata.AlternateEmailId, AlternameMobile = Userdata.HomePhoneNumber, cityName = Userdata.PresentCity, AlternatecityName = Userdata.PermanentCity }; return(View(Info)); } return(RedirectToAction("Login", "Account", new { area = "" })); }
public void Users_InsertUser_ValidUserModel() { //Arrange var id = "A"; var newuser = new UserDetailsDTO() { Address = "address5", City = "city8", Country = "c5", FirstName = "aaaa", LastName = "Vor" }; UserDetails u = new UserDetails() { //Id = id, City = newuser.City, FirstName = newuser.FirstName, LastName = newuser.LastName, Country = newuser.Country, Address = newuser.Address }; _mockMapper.Setup(x => x.Map <UserDetails>(newuser)).Returns(u); _mockRepository.Setup(x => x.Insert(u)).Callback(() => _userList.Add(u)); //Act _userService.Insert(newuser); //Assert Assert.AreEqual(id, u.Id); _mockUnitOfWork.Verify(m => m.Save(), Times.Once); }
public async Task Handler_should_return_user_dto_with_roles(string role) { //Arrange var fakeUser = new User { Id = Guid.NewGuid().ToString() }; var fakeUserDTO = new UserDetailsDTO { Id = fakeUser.Id }; IList <string> roles = new List <string> { role }; _userManagerMock.Setup(x => x.GetRolesAsync(fakeUser)).Returns(Task.FromResult(roles)); _userManagerMock.Setup(x => x.FindByIdAsync(fakeUser.Id)).Returns(Task.FromResult(fakeUser)); _mapperMock.Setup(x => x.Map <User, UserDetailsDTO>(fakeUser)).Returns(fakeUserDTO); var queries = new UserQueries(_userManagerMock.Object, _mapperMock.Object); //Act var result = await queries.GetUserAsync(fakeUser.Id); //Assert Assert.Equal(fakeUserDTO, result); Assert.True(result.Roles.Select(z => z.Name).SequenceEqual(roles)); }
public void Insert(UserDetailsDTO userDTO) { var user = _mapper.Map <UserDetails>(userDTO); user.DateOfBirth = new DateTime(1970, 1, 1); _db.Users.Insert(user); _db.Save(); }
public JsonResult GetUserDetailData(UserDetailsDTO userDetailsDTO) { UserDetailsData userDetailsData = new UserDetailsData(); var data = userDetailsData.GetUserdetails(userDetailsDTO); return(new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult AddUserDetailData(UserDetailsDTO userDetails) { UserDetailsData userDetailsData = new UserDetailsData(); var Data = userDetailsData.AddUserDetails(userDetails); return(new JsonResult { Data = Data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> GetToken([FromBody] UserDetailsDTO userDetails) { // 1) try login, with userDetails //ILoginService loginService = new LoginService(); // loginService.TryAdminLogin(userDetails.Name, userDetails.Password, out LoginToken<Admin> tokenAdmin); //facadeAdmin = FlightsCenterSystem.GetInstance().GetFacade(tokenAdmin) as LoggedInAdministratorFacade; try { await Task.Run(() => FlightsCenterSystem.GetInstance().Login(userDetails.Name, userDetails.Password)); } catch (IllegalFlightParameter ex) { return(Unauthorized("login failed")); } // 2) create key // security key string securityKey = "this_is_our_supper_long_security_key_for_token_validation_project_2018_09_07$smesk.in"; // symmetric security key var symmetricSecurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); // signing credentials var signingCredentials = new SigningCredentials(symmetricSecurityKey, SecurityAlgorithms.HmacSha256Signature); // 3) create claim for specific role // add claims var claims = new List <Claim>(); // create claim according to login -- Airline or Admin or ... claims.Add(new Claim(ClaimTypes.Role, "Administrator")); claims.Add(new Claim(ClaimTypes.Role, "AirlineCompany")); claims.Add(new Claim("username", "userDetails.Name")); // claims.Add(new Claim("Id", "110")); // 4) create token var token = new JwtSecurityToken( issuer: "smesk.in", // change to something better audience: "readers", // change to something better expires: DateTime.Now.AddHours(1), // should be configurable signingCredentials: signingCredentials, claims: claims); // 5) return token return(Ok(new JwtSecurityTokenHandler().WriteToken(token))); }
public static UserDetailsDTO MapToDetails(this User user) { UserDetailsDTO userDTO = new UserDetailsDTO() { //Id = user.Id, //Email = user.Email, //Username = user.UserName }; return userDTO; }
public UserDetailsDTO UserDetails(UserDetailsDTO userDetails) { var data = _mapper.Map <TblUserDetails>(userDetails); _context.TblUserDetails.Add(data); _context.SaveChanges(); var result = _mapper.Map <UserDetailsDTO>(data); return(result); }
public static UserDetailsDTO MapToDetails(this User user) { UserDetailsDTO userDTO = new UserDetailsDTO() { //Id = user.Id, //Email = user.Email, //Username = user.UserName }; return(userDTO); }
public async Task <IActionResult> CreateUserDetails(UserDetailsDTO userDetails) { await this.repository.Insert(new UserDetails { Email = userDetails.Email, FirstName = userDetails.FirstName, LastName = userDetails.LastName, user = await this.context.Users.FindAsync(userDetails.userId) }); return(StatusCode(201)); }
public Result Save(UserDetailsDTO obj) { try { using (DbCommand cmd = Common.dbConn.GetStoredProcCommand("MSTUserDetailsSave")) { Common.dbConn.AddInParameter(cmd, "UserCode", DbType.Int32, obj.Id); Common.dbConn.AddInParameter(cmd, "UserName", DbType.String, obj.UserName); Common.dbConn.AddInParameter(cmd, "Password", DbType.String, obj.Password); Common.dbConn.AddInParameter(cmd, "Gender", DbType.Int32, obj.Gender); if (obj.DOB == DateTime.MinValue) { Common.dbConn.AddInParameter(cmd, "DOB", DbType.Date, System.DBNull.Value); } else { Common.dbConn.AddInParameter(cmd, "DOB", DbType.Date, obj.DOB); } if (obj.DOJ == DateTime.MinValue) { Common.dbConn.AddInParameter(cmd, "DOJ", DbType.Date, System.DBNull.Value); } else { Common.dbConn.AddInParameter(cmd, "DOJ", DbType.Date, obj.DOJ); } if (obj.DOL == DateTime.MinValue) { Common.dbConn.AddInParameter(cmd, "DOL", DbType.Date, System.DBNull.Value); } else { Common.dbConn.AddInParameter(cmd, "DOL", DbType.Date, obj.DOL); } Common.dbConn.AddInParameter(cmd, "Department", DbType.Int32, obj.Department); Common.dbConn.AddInParameter(cmd, "Location", DbType.Int32, obj.Location); Common.dbConn.AddInParameter(cmd, "Designation", DbType.Int32, obj.Designation); Common.dbConn.AddInParameter(cmd, "SoftwareRole", DbType.Int32, obj.SoftwareRole); Common.dbConn.ExecuteNonQuery(cmd); return(new Result { Id = 1, Message = "Saved", ResultStatus = OperationStatus.SavedSuccessFully }); } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Post([FromBody] UserDetailsDTO userDto) { if (userDto == null) { // return HTTP 400 badrequest as something is wrong return(BadRequest("User information formatted incorrectly.")); } // Generate the 'user rewards' for this new 'user' ready for insertion to the DB so, that the user has a complete // list of rewards and challenges so, they can participate in reward and challenge completion. var rewards = await _rewardRepository.GetAllRewards(); var userRewards = (List <UserReward>)GenerateUserRewards(rewards); // Create new user var user = new User() { Id = userDto.Id, First_name = userDto.First_name, Last_name = userDto.Last_name, Created_at = DateTime.UtcNow, Email = userDto.Email, Level = userDto.Level, EcologicalMeasurements = new List <EcologicalMeasurement>(), LivingSpace = userDto.LivingSpace, NumPeopleHousehold = userDto.NumPeopleHousehold, CarMPG = userDto.CarMPG, ShareData = userDto.ShareData, Country = userDto.Country, UserRewards = userRewards, GrantedRewards = new List <Bin>() }; // Save the new user to the DB var result = await _userRepository.CreateUser(user); if (result == 1) { // return HTTP 201 Created with user object in body of return and a 'location' header with URL of newly created object return(CreatedAtAction("Get", new { id = userDto.Id }, user)); } else if (result == -10) { // return HTTP 409 Conflict as user already exists in DB return(Conflict("User with ID '" + userDto.Id + "' already exists. Cannot create a duplicate.")); } else { // return HTTP 400 badrequest as something is wrong return(BadRequest("An internal error occurred. Please contact the system administrator.")); } }
public bool SaveUser([FromBody] UserDetailsDTO userDetails) { if (userDetails != null) { UserManager userManager = new UserManager(); var response = userManager.SaveUser(userDetails); return(response); } else { return(false); } }
public async Task <ActionResult> GetToken([FromBody] UserDetailsDTO userDetails) { ILoginToken login; try { login = await Task.Run(() => { FlightCenterSystem.Instance.Login(out FacadeBase facade, out ILoginToken loginToken, userDetails.Name, userDetails.Password); return(loginToken); }); } catch (WrongCredentialsException) { return(Unauthorized("Login Failed")); } User user = GetUser(login); string role = GetUserRole(user); string securityKey = "this_is_our_supper_long_security_key_for_token_validation_project_2018_09_07$smesk.in"; // symmetric security key var symmetricSecurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); // signing credentials var signingCredentials = new SigningCredentials(symmetricSecurityKey, SecurityAlgorithms.HmacSha256Signature); // 3) create claim for specific role // add claims var claims = new List <Claim>(); claims.Add(new Claim(ClaimTypes.Role, role)); // --> here use the role from the login result claims.Add(new Claim("userid", user.Id.ToString())); // --> here use the user_id from the result claims.Add(new Claim("username", user.User_Name)); // --> here use the name from the login result claims.Add(new Claim("mainUserId", GetRealUserId(login).ToString())); // 4) create token var token = new JwtSecurityToken( issuer: "smesk.in", // change to something better audience: "readers", // change to something better expires: DateTime.Now.AddHours(1), // should be configurable signingCredentials: signingCredentials, claims: claims); // 5) return token return(Ok(new JwtSecurityTokenHandler().WriteToken(token))); }
private UserDetailsModel CreateUserDetailsModel(UserDetailsDTO userDetaislDTO) { var permissionFactory = new PermissionFactory(); return new UserDetailsModel() { UserId = userDetaislDTO.UserId, UserName = userDetaislDTO.UserName, BU = userDetaislDTO.BU, GPN = userDetaislDTO.GPN, LocationId = userDetaislDTO.LocationId, Mail = userDetaislDTO.Mail, SMU = userDetaislDTO.SMU, Permissions = userDetaislDTO.Permission.Select(permissionFactory.CreatePermissionLocationModel).ToList() }; }
public static UserDetailsDTO CreateUserDetails(int userID, int numberOfLoans, int pageNumber, int?pageSize) { var userDetails = new UserDetailsDTO { ID = userID, Name = String.Format("User {0}", userID), Email = String.Format("user@user{0}.com", userID), Address = String.Format("{0} Main Street", userID), }; var loans = CreateUserLoans(numberOfLoans); var envelope = CreateUsersLoansEnvelope(loans, pageNumber, pageSize); userDetails.LoanHistory = envelope; return(userDetails); }
public async Task <IActionResult> SaveUser(int id, UserDetailsDTO user) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var userFromRepo = await userRepository.GetUser(id); mapper.Map(user, userFromRepo); if (await userRepository.SaveAll()) { return(NoContent()); } throw new Exception($"Updating user with id: {id} failed..."); }
public async Task <ActionResult> ChangeMyPassword([FromBody] UserDetailsDTO userDetails) { LoginToken <AirlineCompany> token = GetLoginToken(); try { await Task.Run(() => m_facade.ChangeMyPassword(token, token.User.Password, userDetails.Password)); } catch (WrongCredentialsException ex) { return(StatusCode(403, $"{{ error: \"{ex.Message}\" }}")); } catch (WasntActivatedByAirlineException ex) { return(StatusCode(401, $"{{ error: \"{ex.Message}\" }}")); } return(Ok()); }