public ActionResult Register(UserVM iUser) { ActionResult oResponse = null; if (ModelState.IsValid) //if info correct { try { //Maping assigned into a variable IUserDO Userform = UserMap.MapPOtoDO(iUser.User); //Method used from DAL UserAccess.Register(Userform); //Return to login view oResponse = RedirectToAction("Login", "User"); } catch (Exception e) { iUser.ErrorMessage = "Sorry we can preform that task at the moment, try again later"; ErrorLog.LogError(e); oResponse = View(iUser); } finally { //Onshore standards } } else //if incorrect info { oResponse = View(iUser); } return(oResponse); }
public override string ToString() { var sb = new StringBuilder("Insanity("); int tmp20 = 0; if ((UserMap != null) && __isset.userMap) { if (0 < tmp20++) { sb.Append(", "); } sb.Append("UserMap: "); UserMap.ToString(sb); } if ((Xtructs != null) && __isset.xtructs) { if (0 < tmp20++) { sb.Append(", "); } sb.Append("Xtructs: "); Xtructs.ToString(sb); } sb.Append(')'); return(sb.ToString()); }
public ActionResult ViewUsers() { UserVM newVM = new UserVM(); if (Session["UserName"] != null && (int)Session["UserLevel"] == 1) { try { //create new list List <IuserInfoDO> userData = _UserAccess.ViewAllUsers(); //map info from data to presentation obj newVM.UserList = UserMap.MapDOtoPO(userData); } catch (Exception) { //pass error to user here in presentation layer, error has already been logged newVM.ErrorMessage = "There was an issue obtaining the list"; } finally { ///nothing else needs to happen } return(View(newVM)); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult CreateUser(UserViewModel userInfo) { ActionResult response = null; try { if (Session["UserName"] == null) { UserPO form = userInfo.Form; if (ModelState.IsValid) { UserMap map = new UserMap(); UserDO userObject = map.UserPOToDO(form); userObject.RoleID = 1; userDL.CreateUser(userObject); response = RedirectToAction("Login", "Account"); } else { response = View(userInfo); } } else { response = RedirectToAction("Index", "Home"); } } catch (SqlException sqlEx) { //What about the exception do we wish to analyze? userInfo.message = new ExceptionAnalysis().GenerateResponse(sqlEx); response = View(userInfo); } return(response); }
private UserMap getUsermapsValues(ISession session, ILog log, int cid) { UserMap result = new UserMap(); try { string AsUserMaker = ParameterHelper.GetString("PAYROLL_KAI_USER_MAKER", session); //UserMap umap=session.CreateCriteria(typeof(UserMap)) // .Add(Expression.Eq("ClientEntity", cid)) // .Add(Expression.Eq("UserHandle", "ADMIN")) // .UniqueResult<UserMap>(); UserMap umap = session.CreateCriteria(typeof(UserMap)) .Add(Expression.Eq("ClientEntity", cid)) .Add(Expression.Eq("UserHandle", AsUserMaker)) .UniqueResult <UserMap>(); if (umap != null) { result = umap; } } catch (Exception ex) { log.Error("== " + SchedulllerCode + " = Scheduller GetFilePayrollKai Failed to Start => Exception Message =" + " " + ex.Message); log.Error("== " + SchedulllerCode + " = Scheduller GetFilePayrollKai Failed to Start => Exception InnerMessage =" + " " + ex.InnerException); log.Error("== " + SchedulllerCode + " = Scheduller GetFilePayrollKai Failed to Start => Exception StackTrace =" + " " + ex.StackTrace); } return(result); }
/// <summary> /// Likes the comment. /// </summary> /// <param name="user">The user map.</param> /// <param name="contentId">The content id.</param> /// <param name="commentId">The comment id.</param> /// <param name="commentTable">The comment table.</param> public static int LikeComment(UserMap user, Guid contentId, Guid commentId, CommentTables commentTable) { using (var connection = new SqlConnection(Settings.ADONetConnectionString)) { connection.Open(); var query = string.Format("IF (SELECT COUNT(*) FROM {0} WHERE ContentID = @ContentID AND SiteID = @SiteID) > 0 " + "BEGIN " + "DECLARE @CommentMarkID uniqueidentifier " + "SELECT @CommentMarkID = ID FROM {0}Mark WHERE ContentCommentID = @CommentID AND UserID = @UserID " + "IF @CommentMarkID IS NULL " + "BEGIN " + "SET @CommentMarkID = newid() " + "INSERT INTO {0}Mark ([ID], [ContentCommentID], [UserID], [TypeID], [Rank]) " + "VALUES (@CommentMarkID, @CommentID, @UserID, 0, 1) " + "END " + "ELSE " + "UPDATE {0}Mark " + "SET Rank = (CASE WHEN Rank = 1 THEN 0 ELSE 1 END) " + "WHERE ContentCommentID = @CommentID AND UserID = @UserID " + "SELECT Rank FROM {0}Mark WHERE ID = @CommentMarkID " + "END " + "ELSE " + "SELECT 1", commentTable.ToString()); using (var command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@ContentID", contentId); command.Parameters.AddWithValue("@CommentID", commentId); command.Parameters.AddWithValue("@SiteID", user.SiteID); command.Parameters.AddWithValue("@UserID", user.ID); return(int.Parse(command.ExecuteScalar().ToString())); } } }
private UserMap AddUserMap(DbTransaction transaction, UserMap userMap) { if (userMap == null) { throw new ArgumentNullException("userMap"); } var sql = @"INSERT INTO [dbo].[User_UserMap] ([UserId] ,[LevelNumber],[TeamNumber],[ChildNode],[ParentMap]) VALUES(@UserId,@LevelNumber,@TeamNumber,@ChildNode ,@ParentMap);select @@identity;"; var parameters = new[] { RepositoryContext.CreateParameter("@UserId", userMap.UserId), RepositoryContext.CreateParameter("@LevelNumber", userMap.LevelNumber), RepositoryContext.CreateParameter("@TeamNumber", userMap.TeamNumber), RepositoryContext.CreateParameter("@ChildNode", userMap.ChildNode), RepositoryContext.CreateParameter("@ParentMap", userMap.ParentMap) }; var result = RepositoryContext.ExecuteScalar(transaction, sql, parameters); if (result != null && result != DBNull.Value) { userMap.Id = Convert.ToInt64(result); } return(userMap); }
public static List <User> ReadAllUsers() { DataTable DTuser = UserDataManager.GetAllUsers(); DataTable DTrole = UserDataManager.GetAllRoles(); DataTable DTteam = UserDataManager.GetAllTeams(); List <User> allUsers = UserMap.MapUserData(DTuser, DTrole, DTteam); HttpContext.Current.Session.Add(SessionManager.UserSession, allUsers); _allUsers = allUsers; return(_allUsers); //string filePath = _dataPath + "/User"; //List<User> users = new List<User>(); //if (Directory.Exists(filePath)) //{ // string[] files = Directory.GetFiles(filePath); // foreach (string file in files) // { // User user = XMLUtil.ReadFromXmlFile<User>(file); // users.Add(user); // } //} //else // Directory.CreateDirectory(filePath); //return users; }
public ActionResult ViewUserbyID(long UserID) { ActionResult oResponse = null; if (Session["Username"] == null) //Guest { oResponse = RedirectToAction("Index", "Home"); } else { UserVM newVM = new UserVM(); //creating new instance try { //Uses method from DAL then assigns to variable IUserDO userInfo = UserAccess.ViewUsersByID(UserID); //Mapping assigned to variable newVM.User = UserMap.MapDOtoPO(userInfo); //Return this view oResponse = View(newVM); } catch (Exception e) { newVM.ErrorMessage = "Sorry we cannot process your request at this time"; ErrorLog.LogError(e); oResponse = View(newVM); } finally { //Onshore standards } } return(oResponse); }
public ActionResult ViewUsers() { ActionResult oResponse = null; if (Session["Username"] == null || (Int16)Session["Role"] != 1) { //Guest, User, Power User oResponse = RedirectToAction("Index", "Home"); } else //Admin { UserVM newVM = new UserVM(); //create new instance try { //Use of method from DAL assigned in a variable List <IUserDO> userInfo = UserAccess.ViewAllUsers(); //Mapping assigned in a variable newVM.UserList = UserMap.MapDOtoPO(userInfo); //return view oResponse = View(newVM); } catch (Exception e) { newVM.ErrorMessage = "Sorry we cannot process your request at this time"; ErrorLog.LogError(e); oResponse = View(newVM); } finally { //Onshore standards } } return(oResponse); }
public async Task <IActionResult> SilentLogin([FromBody] LoginCredentials credentials) { // Check if the user already exists in the database UserMap userMap = await this._dataProvider.GetUserMapByUserName(credentials.Email); User user = null; if (userMap != null) { // User Map exists, fetch the user's account from the database // TO DO : Validate user's credentials here via Identity Framework (Claims) before proceeding user = await this._dataProvider.GetUser(userMap.AcctId); if (user != null) { PopulateUserStats(user); } else { return(BadRequest()); } // Overwrite the password to hold the Identity Id //user.Password = identityUser.Id; user.Password = ""; return(Ok(user)); } else { return(BadRequest()); } }
public async Task <IActionResult> Register([FromBody] SignUpCredentials credentials) { // Check if the user already exists in the database UserMap userMap = await this._dataProvider.GetUserMapByUserName(credentials.Email); // If user already exists in the database, return a BadRequest error if (userMap != null) { return(BadRequest()); } // Attempt to create a new Identity User using the provided credentials var identityUser = new IdentityUser { UserName = credentials.Email, Email = credentials.Email }; var result = await _userManager.CreateAsync(identityUser, credentials.Password); if (!result.Succeeded) { return(BadRequest(result.Errors)); } await _signInManager.SignInAsync(identityUser, isPersistent : false); // Create a Security Token string authToken = _userAuthContext.CreateAuthToken(identityUser); // Set the User class User user = new User { UserName = credentials.Email, Email = credentials.Email, Password = credentials.Password, FirstName = credentials.FirstName, LastName = credentials.LastName, AuthToken = authToken, GameCredits = 10000, GameCurrency = 100, Status = 1 }; // Create the user and add mappings in the database await this._dataProvider.AddUser(user); User createdUser = await this._dataProvider.GetUserByUserName(credentials.Email); user.AcctId = createdUser.AcctId; await this._dataProvider.AddUserMap(user.Email, user.AcctId); await this._dataProvider.AddIdentityMap(identityUser.Id, user.AcctId); // Overwrite the password to hold the Identity Id user.Password = identityUser.Id; user.TotalBoards = 0; user.TotalComments = 0; return(Ok(user)); }
protected void btnZoomAll(object sender, System.EventArgs e) { Map map = GetMapObj(); UserMap.ZoomAll(map); //map.SetView(map.Layers.Bounds, map.GetDisplayCoordSys()); }
private unsafe void FillImageFromUserMap(UserMap um) { int[] colors = { 16777215, 14565387, 32255, 7996159, 16530175, 8373026, 14590399, 7062435, 13951499, 55807 }; if (this.image == null || this.image.Width != um.FrameSize.Width || this.image.Height != um.FrameSize.Height) { this.image = new Bitmap(um.FrameSize.Width, um.FrameSize.Height, PixelFormat.Format24bppRgb); } BitmapData bd = this.image.LockBits( new Rectangle(new Point(0, 0), this.image.Size), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb); for (int y = 0; y < um.FrameSize.Height; y++) { ushort *dataPos = (ushort *)((byte *)um.Pixels.ToPointer() + (y * um.DataStrideBytes)); byte * imagePos = (byte *)bd.Scan0.ToPointer() + (y * bd.Stride); for (int x = 0; x < um.FrameSize.Width; x++) { int color = colors[*dataPos % colors.Length]; * imagePos = (byte)(((color / 1) % 256) * *dataPos); // R imagePos++; *imagePos = (byte)(((color / 256) % 256) * *dataPos); // G imagePos++; *imagePos = (byte)(((color / 65536) % 256) * *dataPos); // B imagePos++; dataPos++; } } this.image.UnlockBits(bd); }
public ActionResult UpdateUser(UserViewModel userInfo) { ActionResult response = null; try { if ((Int64)Session["RoleID"] == 3) { UserPO form = userInfo.Form; UserMap map = new UserMap(); if (ModelState.IsValid) { UserDO userObject = map.UserPOToDO(form); userDL.UpdateUser(userObject); response = RedirectToAction("UserIndex"); } else { response = View(userInfo); } } else { response = RedirectToAction("Index", "Home"); } } catch (SqlException sqlEx) { userInfo.message = new ExceptionAnalysis().GenerateResponse(sqlEx); response = View(userInfo); } return(response); }
public void ParseUserFile_MissingEmail() { using (var reader = new StringReader(UserMapResources.MissingEmail)) { var map = new UserMap("example.com"); map.ParseUserFile(reader, "User File"); } }
public void ParseUserFile_Duplicate() { using (var reader = new StringReader(UserMapResources.Duplicate)) { var map = new UserMap("example.com"); map.ParseUserFile(reader, "User File"); } }
public void ParseUserFile_ExtraField() { using (var reader = new StringReader(UserMapResources.ExtraField)) { var map = new UserMap("example.com"); map.ParseUserFile(reader, "User File"); } }
/// <summary> /// shinbo added /// 更改坐标系为LON/LAT方式 /// add templayer /// add labellayer /// </summary> protected void InitWorkingLayer() { Map map = GetMapObj(); //CoordSys csysWGS84 = MapInfo.Engine.Session.Current.CoordSysFactory.CreateCoordSys("EPSG:4326"); //map.SetDisplayCoordSys(csysWGS84); UserMap.CreateTempLayer(map, Constants.TempTableAlias, Constants.TempLayerAlias); UserMap.ShowLabelLayer(map, Constants.TempTableAlias, "name"); }
/// <summary> /// Shows the menu items. /// </summary> private async Task ShowMenuItems() { var speed = 25U; await Settings.FadeTo(1, speed); await Followings.FadeTo(1, speed); await UserMap.FadeTo(1, speed); }
public void GetUser_NotFound() { var map = new UserMap("example.com"); var user = map.GetUser("fred"); Assert.AreEqual(user.Name, "fred"); Assert.AreEqual(user.Email, "*****@*****.**"); Assert.IsTrue(user.Generated); }
private OrganisationUserMap MakeTestOrganisationUserMap() { var addressMapper = new AddressMap(); var contactMapper = new ContactMap(); var userMapper = new UserMap(); var orgMapper = new OrganisationMap(addressMapper, contactMapper); return(new OrganisationUserMap(orgMapper, userMapper)); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); #region [ Maps of the Context ] UserMap.OnCreateTable(ref modelBuilder); #endregion }
public async Task EditUser(UserBE user, CancellationToken token) { var existingUser = await _flightplanner_entities.User.Where(x => x.Id == user.Id).FirstOrDefaultAsync(); if (existingUser != null) { UserMap.Map(user, existingUser); await Save(token); } }
public ActionResult UpdateUser(UserVM changeUser) { ActionResult oResult = null; if (Session["UserName"] != null && (int)Session["UserLevel"] == 1) { //if the info was entered as required if (ModelState.IsValid) { try { IuserInfoDO updateUser = UserMap.MapPOtoDO(changeUser.User); //call to producer data access method _UserAccess.UpdateUser(updateUser); } catch (Exception e) { //what to do with exception, what to write if (e.Message.Contains("duplicate")) { changeUser.ErrorMessage = "Unable to process request, duplicate record already exists"; } else { changeUser.ErrorMessage = "We apologize but we were unable to handle your request at this time."; } } finally { } if (changeUser.ErrorMessage == null) { //if no errors take them to producer list to see if their submission was added oResult = RedirectToAction("ViewUsers", "User"); } else { //if any errors caught then redirect to screen to change producer info, same as they came from oResult = View(changeUser); } } else { oResult = View(changeUser); } } else { oResult = RedirectToAction("Login", "User"); } return(oResult); }
public ActionResult GetList() { var list = _service.GetUserList(); List <UserModel> models = new List <UserModel>(); foreach (var item in list) { models.Add(UserMap.AutoMap(item)); } return(JsonList(models, models.Count)); }
public DTOModelMapperTest() { var resolver = new Mock<IMapperResolver>(); mapper = new SmartMapper<DTO, Model>(resolver.Object); var productMap = new ProductMap(); var userMap = new UserMap(); resolver.Setup(x => x.Resolve(typeof (IMapper<DTOProduct, Model>))).Returns(productMap); resolver.Setup(x => x.Resolve(typeof (IMapper<DTOUser, Model>))).Returns(userMap); }
/// <summary> /// Instala os mapeamentos dos modelos para o MongoDB /// </summary> public static void Install() { // Define como Camel Case o nome das chaves de cada registro no banco de dados ConventionPack conventionPack = new ConventionPack { new CamelCaseElementNameConvention() }; ConventionRegistry.Register("camelCase", conventionPack, t => true); AuctionMap.Configure(); AuctionResponsibleUserMap.Configure(); UserMap.Configure(); }
protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); if (builder == null) { throw new ArgumentNullException(nameof(builder), $"Cannot create Context Model with a null {nameof(ModelBuilder)}."); } UserMap.Map(builder.Entity <User>()); UserProfileMap.Map(builder.Entity <UserProfile>()); MapTableNames(builder); }
private UserMap ReadUserMap(IDataReader reader) { var userMap = new UserMap { Id = reader["DetailId"].ConvertToLong(0), UserId = reader["Id"].ConvertToLong(), LevelNumber = reader["LevelNumber"].ConvertToLong(), TeamNumber = reader["TeamNumber"].ConvertToLong(), ChildNode = reader["ChildNode"].ToString(), ParentMap = reader["ParentMap"].ToString() }; return(userMap); }
//dipake payroll private static Boolean CekAuthority(ISession session, int fid, UserMap umap, String trxCode, String valuedate, double trxAmount, String currtrx, out String error) { bool result = true; error = ""; AuthorityHelper ah = null; try { ClientMatrix cm = session.Load <ClientMatrix>(umap.ClientEntity); UserMatrix um = session.Load <UserMatrix>(umap.UserEntity); if (!currtrx.Trim().Equals("IDR")) { Currency curr = session.CreateCriteria(typeof(Currency)) .Add(Expression.Like("Code", "%" + currtrx.Trim() + "%")) .UniqueResult <Currency>(); trxAmount = double.Parse((trxAmount * (double)curr.BookingRate).ToString()); } //Limit Korporasi ah = new AuthorityHelper(cm.Matrix); if (!ah.OnUserLimit(fid.ToString(), trxAmount)) { error += "Melewati limit per transaksi corporate*"; } //Limit User ah = new AuthorityHelper(um.Matrix); if (!ah.OnUserLimit(fid.ToString(), trxAmount)) { error += "Melewati limit per transaksi user*"; } //Total Limit Harian String resultLimit = TotalOBHelper.onTotalHarianLimit(session, umap.ClientEntity, trxCode, valuedate, currtrx.Trim(), trxAmount); if (!resultLimit.Contains("[VALID]")) { error += resultLimit + "*"; } } catch (Exception he) { error = he.Message + "||" + he.StackTrace + "||" + he.InnerException; result = false; } return(result); }
public void Create() { string userName = Guid.NewGuid().ToString(); Guid userId = Guid.NewGuid(); string line1 = Guid.NewGuid().ToString(); string postcodeInward = "PL21"; string postcodeOutward = "9TY"; IDataReader stubReader = GetStubReader(userName, userId, line1, postcodeInward, postcodeOutward); UserMap map = new UserMap(); User user = map.Create(stubReader); Assert.AreEqual(userName, user.Name); Assert.AreEqual(userId, user.Id); Assert.IsNotNull(user.Address); Assert.AreEqual(line1, user.Address.Line1); Assert.IsNotNull(user.Address.PostCode); Assert.AreEqual("PL21 9TY", user.Address.PostCode.Value); }
public void Populate() { string userName = Guid.NewGuid().ToString(); Guid userId = Guid.NewGuid(); string line1 = Guid.NewGuid().ToString(); string postcodeInward = "BS6"; string postcodeOutward = "6LT"; IDataReader stubReader = GetStubReader(userName, userId, line1, postcodeInward, postcodeOutward); User user = new User(); UserMap map = new UserMap(); map.Populate(user, stubReader); Assert.AreEqual(userName, user.Name); Assert.AreEqual(userId, user.Id); Assert.IsNotNull(user.Address); Assert.AreEqual(line1, user.Address.Line1); Assert.IsNotNull(user.Address.PostCode); Assert.AreEqual("BS6 6LT", user.Address.PostCode.Value); }
private OrganisationUserMap MakeTestOrganisationUserMap() { var addressMapper = new AddressMap(); var contactMapper = new ContactMap(); var userMapper = new UserMap(); var orgMapper = new OrganisationMap(addressMapper, contactMapper); return new OrganisationUserMap(orgMapper, userMapper); }
public void Constructor() { UserMap map = new UserMap(); }