public async Task <bool> Register(RegisterRequest request) { if (request != null) { var check = await db.Users.FirstOrDefaultAsync(u => u.Email.Equals(request.Email)); if (check != null) { return(false); } else { var user = new Data.Entities.User() { FirstName = request.FirstName, LastName = request.LastName, Address = request.Address, City = request.City, State = request.State, PhoneNumber = request.PhoneNumber, Email = request.Email, DOB = request.DOB, CurrentDate = DateTime.Now, Password = request.Password }; await db.Users.AddAsync(user); await db.SaveChangesAsync(); return(true); } } return(false); }
public async Task CMD_dardinero(Player player, int id, double dinero) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); //var user = player.GetExternalData<Data.Entities.User>(0); if (user.adminLv >= 5) { Player target = Utilities.PlayerId.FindPlayerById(id); if (target == null) { Utilities.Notifications.SendNotificationERROR(player, "No hay ningún jugador conectado con esta id"); } else { await Money.MoneyModel.AddMoney(target, dinero); Utilities.Notifications.SendNotificationOK(player, $"Le has dado ${dinero} a {target.Name}"); Utilities.Notifications.SendNotificationOK(target, $"Un administrador te ha entregado ${dinero}"); Utilities.Webhooks.sendWebHook(1, $"💲 [{DateTime.Now.ToString()}] {player.Name} le ha dado ${dinero} a {target.Name}"); } } }
public List <Team> GetUserTeams(User user) { List <Team> x = new List <Team>(); //list to store teams and ultimately return int i = 0; //index variable for loops List <int> teamIDs = new List <int>(); //list to store team IDs to try and create team objects //first get the users user ID (primary key) Data.Entities.User DBUser = _db.User.Where(z => z.Username.Equals(user.username)).FirstOrDefault(); if (DBUser != null) { int userID = DBUser.Id; //now, get all of the UserTeam entities that contain that specific userID, along with the teams List <Data.Entities.UserTeam> DBUserTeam = _db.UserTeam.Where(y => y.Userid == userID).Include("Team").ToList(); //now create a list of team objects based on the above for (i = 0; i < DBUserTeam.Count; i++) { Team team = new Team(); team.id = DBUserTeam[i].Team.Id; team.teamname = DBUserTeam[i].Team.Teamname; x.Add(team); } } //and finally return x, a list of teams after all that jumping around! return(x); }
public async Task CMD_borrarnegocio(Player player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (user.isInBusiness) { user.business.label.Delete(); user.business.blip.Delete(); user.business.marker.Delete(); user.business.shape.Delete(); user.business = null; await World.Business.DbFunctions.DeleteBusiness(user.business.id); Utilities.Notifications.SendNotificationOK(player, $"Has borrado un negocio correctamente"); } else { Utilities.Notifications.SendNotificationERROR(player, "No estás en un negocio"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public async Task CMD_crearnegociospawn(Player player) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (!player.HasData("CREATE_VEHICLE_BUSINESS")) { Utilities.Notifications.SendNotificationERROR(player, "Debes usar primero /crearvehiculosnegocio en la entrada de un negocio"); return; } Data.Entities.Business business = player.GetData <Data.Entities.Business>("CREATE_VEHICLE_BUSINESS"); if (business.spawn != null) { Utilities.Notifications.SendNotificationERROR(player, "Este negocio ya tiene punto de spawn"); return; } await World.Business.DbFunctions.CreateBusinessVehicleSpawn(business.id, player.Position.X, player.Position.Y, player.Position.Z, player.Heading); business.spawn = player.Position; business.spawnRot = player.Heading; Utilities.Notifications.SendNotificationOK(player, "Has creado el punto de spawn correctamente"); } }
public async Task CMD_borrarempresa(Player player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (user.isInCompany) { user.company.label.Delete(); user.company.blip.Delete(); user.company.marker.Delete(); user.company.shape.Delete(); Data.Lists.Companies.Add(user.company); user.company = null; await World.Companies.DbFunctions.DeleteCompany(user.company.id); Utilities.Notifications.SendNotificationOK(player, $"Has borrado una empresa correctamente"); } else { Utilities.Notifications.SendNotificationERROR(player, "No estás en una empresa"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public void CMD_crearnegocio(Player player, int type, int price) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (type == 1 || type == 2 || type == 3 || type == 4 || type == 5 || type == 6 || type == 7 || type == 8 || type == 9) { //player.SetData<int>("CreateCompanyType", type); //player.SetData<int>("CreateCompanyPrice", price); player.SetData("CreateBusinessType", type); player.SetData("CreateBusinessPrice", price); player.TriggerEvent("BusinessAddStreetName"); } else { Utilities.Notifications.SendNotificationERROR(player, "No existe ese tipo de negocio"); } } }
public async Task CMD_crearnegocio(Player player, int type) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { if (type == 1 || type == 2) { int bankId = await World.Banks.DatabaseFunctions.CreateBank(player, type); ColShape bank = NAPI.ColShape.CreateCylinderColShape(player.Position, 2, 6); TextLabel label = NAPI.TextLabel.CreateTextLabel("Pulsa ~y~F5 ~w~para interactuar", player.Position.Subtract(new Vector3(0, 0, 0.1)), 15, 6, 2, new Color(255, 255, 255)); Marker marker = NAPI.Marker.CreateMarker(0, player.Position.Subtract(new Vector3(0, 0, 0.1)), new Vector3(), new Vector3(), 1, new Color(251, 244, 1)); Blip blip = NAPI.Blip.CreateBlip(player.Position); if (type == 1) { blip.Sprite = 108; blip.Scale = 1f; blip.ShortRange = true; blip.Name = "Banco"; blip.Color = 5; } else { blip.Sprite = 277; blip.Scale = 1f; blip.ShortRange = true; blip.Name = "ATM"; blip.Color = 5; } Data.Entities.Bank banco = new Data.Entities.Bank { blip = blip, marker = marker, label = label, id = bankId, type = type }; //bank.SetExternalData<Data.Entities.Bank>(0, banco); bank.SetData("BANK_CLASS", banco); Utilities.Notifications.SendNotificationOK(player, $"Has creado el banco con ID {bankId}"); } else { player.SendChatMessage("<font color='red'>ERROR</font> No existe ese tipo de banco"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public void CMD_borrarveh(Player player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv >= 5) { if (player.IsInVehicle) { Vehicle veh = player.Vehicle; veh.Delete(); } else { Utilities.Notifications.SendNotificationERROR(player, "No estás en un vehículo"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public async void RE_RegisterPlayerAccount(Client player, string username, string email, string password, string repassword) { if (await DatabaseFunctions.CheckIfPlayerRegistered(username) == false) { if (await DatabaseFunctions.CheckIfEmailRegistered(email) == false) { if (password == repassword) { int playerId = await DatabaseFunctions.RegisterPlayer(username, password, email, player.SocialClubName, player.Address); Data.Entities.User user = new Data.Entities.User { id = playerId }; //player.SetExternalData<Data.Entities.User>(0, user); player.SetData("USER_CLASS", user); Console.WriteLine($"Registrado {playerId}"); } else { player.TriggerEvent("ShowErrorAlert", 4); } } else { player.TriggerEvent("ShowErrorAlert", 3); } } else { player.TriggerEvent("ShowErrorAlert", 2); } }
public void CMD_getid(Player player) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user.adminLv == 5) { player.SendChatMessage("<font color='yellow'>INFO:</font> si no sale ninguna información es porque no se pudo obtener la id"); if (user.isInBank) { player.SendChatMessage($"La id del banco es {user.bankEntity.id}"); } if (user.isInBusiness) { player.SendChatMessage($"La id del negocio es {user.business.id}"); } if (user.isInCompany) { player.SendChatMessage($"La id de la empresa es {user.company.id}"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public async Task RE_LoginPlayerAccount(Client player, string username, string password) { if (await DatabaseFunctions.CheckIfPlayerRegistered(username) == true) { int playerid = await DatabaseFunctions.LoginPlayer(username, password); if (playerid != 0) { player.TriggerEvent("DestroyWindow"); Data.Entities.User user = new Data.Entities.User { id = playerid }; player.SetData("USER_CLASS", user); //player.SetExternalData<Data.Entities.User>(0, user); CharacterSelector.CharacterSelector.RetrieveCharactersList(player); // await Character.DbFunctions.ShowCharacterList(player); <- NUEVO CHARACTER SELECTOR } else { player.TriggerEvent("ShowErrorAlert", 1); } } else { player.TriggerEvent("ShowErrorAlert", 1); } }
public async Task RE_ActionEngineVehicle(Client player) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (!user.chatStatus) { if (player.IsInVehicle) { if (player.Vehicle.EngineStatus) { player.Vehicle.EngineStatus = false; Utilities.Chat.EntornoMe(player, "ha apagado el motor"); player.Vehicle.SetSharedData("ENGINE_STATUS", false); return; } else { Utilities.Chat.EntornoMe(player, "está encendiendo el motor del vehículo"); await Task.Delay(1000); player.Vehicle.EngineStatus = true; Utilities.Chat.EntornoDo(player, "Motor encendido"); player.Vehicle.SetSharedData("ENGINE_STATUS", true); } } } }
public async Task CMD_borrarbanco(Client player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (user.adminLv == 5) { if (user.isInBank) { await World.Banks.DatabaseFunctions.DeleteBank(user.bankEntity.id); user.bankEntity.label.Delete(); user.bankEntity.blip.Delete(); user.bankEntity.marker.Delete(); Utilities.Notifications.SendNotificationOK(player, $"Has borrado un banco correctamente"); } else { Utilities.Notifications.SendNotificationERROR(player, "No estás en un banco"); } } else { player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)"); } }
public void RE_ActionMenuCompany(Client player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (user.isInCompanyInterior) { if (user.companyInterior.owner == user.idpj) { if (!user.isCompanyCefOpen) { player.TriggerEvent("OpenMenuCompany", (int)user.companyInterior.safeBox, user.companyInterior.workers, user.companyInterior.percentage, user.companyInterior.subsidy, user.companyInterior.name); user.isCompanyCefOpen = true; return; } else { player.TriggerEvent("DestroyMenuCompany"); user.isCompanyCefOpen = false; } } } }
public async Task RE_MenuCompanyRetirar(Client player, string cant) { int cantidad = Convert.ToInt32(cant); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); //var user = player.GetExternalData<Data.Entities.User>(0); if (user.companyInterior.owner == user.idpj) { if (user.companyInterior.safeBox <= cantidad) { user.companyInterior.safeBox = user.companyInterior.safeBox - cantidad; await DbFunctions.UpdateCompanySafebox(user.companyInterior.id, (int)user.companyInterior.safeBox); Utilities.Notifications.SendNotificationOK(player, $"Has retirado ${cantidad} de la caja fuerte de tu empresa"); } else { Utilities.Notifications.SendNotificationERROR(player, "No tienes suficiente dinero en la caja fuerte"); } } }
public async Task <ActionResult <Data.Models.User> > PatchUser(int userId, JsonPatchDocument <Data.Models.UserForUpdate> patchDocument) { try { Data.Entities.User dbUser = await _repository.GetUserAsync(userId); if (dbUser == null) { return(NotFound()); } var updatedUser = _mapper.Map <Data.Models.UserForUpdate>(dbUser); patchDocument.ApplyTo(updatedUser, ModelState); _mapper.Map(updatedUser, dbUser); if (await _repository.SaveChangesAsync()) { Data.Models.User savedUser = _mapper.Map <Data.Models.User>(await _repository.GetUserAsync(userId)); return(Ok(savedUser)); } else { return(StatusCode(StatusCodes.Status500InternalServerError, "Unable to save to database")); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Unable to patch user " + ex.Message)); } }
public void OnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seatID) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (vehicle.HasData("VEHICLE_BUSINESS_DATA")) { Data.Entities.VehicleBusiness veh = vehicle.GetData <Data.Entities.VehicleBusiness>("VEHICLE_BUSINESS_DATA"); if (veh.isCompanySelling) { if (user.companyProperty != null) { if (veh.business.spawn != null) { player.TriggerEvent("OpenCarshopBrowser", veh.business.name, veh.model, veh.price); } else { Utilities.Notifications.SendNotificationERROR(player, "Esta empresa no tiene punto de spawn para vehículos. Contacta con un administrador."); } } else { Utilities.Notifications.SendNotificationERROR(player, "No eres dueño de ninguna empresa"); } } } }
public void RE_ActionOpenBuyBusiness(Client player) { if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (user.isInBusiness) { if (user.business.owner == 0) { if (!user.isBusinessCefOpen) { player.TriggerEvent("OpenBusinessBuyBrowser", GetNameTypeBusiness(user.business.type), user.business.price, $"{user.business.area}, {user.business.number}"); user.isBusinessCefOpen = true; return; } else { player.TriggerEvent("DestroyBusinessBuyBrowser"); user.isBusinessCefOpen = false; } } } }
public async Task RE_BuyBusiness(Client player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (user.business != null) { if (await Game.Money.MoneyModel.SubMoney(player, (double)user.business.price)) { await DbFunctions.UpdateBusinessOwner(user.business.id, user.idpj); player.TriggerEvent("DestroyBusinessBuyBrowser"); user.isBusinessCefOpen = false; user.business.owner = user.idpj; user.business.label.Text = $"Negocio~n~Pulsa ~y~F5 ~w~para interactuar~n~{user.business.area}, {user.business.number}"; player.TriggerEvent("chat_goal", "¡Felicidades!", "Ahora eres propietario de un negocio"); await Task.Delay(2000); Utilities.Notifications.SendNotificationINFO(player, "Para configurar tu negocio presiona ~g~F6"); } else { Utilities.Notifications.SendNotificationERROR(player, "No tienes suficiente dinero para comprar este negocio"); } } }
public async Task <ActionResult <Data.Models.User> > CreateNewUser(Data.Models.UserForCreate newUser) { Data.Entities.User dbNewUser = null; try { dbNewUser = _mapper.Map <Data.Entities.User>(newUser); } catch (Exception ex) { return(BadRequest("Input is in invalid format: " + ex.Message)); } if (dbNewUser == null) { return(BadRequest("Input is in invalid format")); } await _repository.AddAsync <Data.Entities.User>(dbNewUser); await _repository.SaveChangesAsync(); Data.Models.User addedUser = _mapper.Map <Data.Models.User>(dbNewUser); var url = _linkgenerator.GetPathByAction(HttpContext, "GetUserByUserId", "Users", addedUser); return(this.Created(url, addedUser)); }
public void Business_EnterColShape(ColShape shape, Client player) { //var business = shape.GetExternalData<Data.Entities.Business>(0); if (!shape.HasData("BUSINESS_CLASS")) { return; } Data.Entities.Business business = shape.GetData("BUSINESS_CLASS"); //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData("USER_CLASS"); if (business != null) { if (business.owner == 0) { player.TriggerEvent("displayBusinessVenta"); } else { if (business.type == 6 || business.type == 7 || business.type == 8) { player.TriggerEvent("adviceBuyVehicle"); } } user.isInBusiness = true; user.business = business; } }
public async Task <IActionResult> PostUser([FromBody] NewUserRequest request) { if (!ModelState.IsValid) { return(BadRequest(new Response { IsSuccess = false, Message = "Bad request" })); } var user = await _userHelper.GetUserByEmailAsync(request.Email); if (user != null) { return(BadRequest(new Response { IsSuccess = false, Message = "This email is already registered." })); } user = new Data.Entities.User { FirstName = request.FirstName, LastName = request.LastName, Email = request.Email, UserName = request.Email, Address = request.Address, PhoneNumber = request.Phone, EmailConfirmed = true }; var result = await _userHelper.AddUserAsync(user, request.Password); if (result != IdentityResult.Success) { return(BadRequest(result.Errors.FirstOrDefault()?.Description)); } return(Ok()); // Email confirmation commented //var myToken = await _userHelper.GenerateEmailConfirmationTokenAsync(user); //var tokenLink = Url.Action("ConfirmEmail", "Account", new //{ // userid = user.Id, // token = myToken //}, protocol: HttpContext.Request.Scheme); //_mailHelper.SendMail(request.Email, "Email confirmation", $"<h1>Email Confirmation</h1>" + // $"To allow the user, " + // $"please click in this link:</br></br><a href = \"{tokenLink}\">Confirm Email</a>"); //return Ok(new Response //{ // IsSuccess = true, // Message = "A Confirmation email was sent. Please confirm your account and log into the App." //}); }
public async static Task <bool> SubMoney(Player player, double money_to_sub) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return(false); } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (money_to_sub <= 0) { return(false); } double actual_money = user.money; if (money_to_sub > actual_money) { return(false); } if (user.money < 0) { user.money = 0; await DatabaseFunctions.UpdateMoney(user.idpj, 0); } double money = actual_money -= money_to_sub; user.money = money; NAPI.ClientEvent.TriggerClientEvent(player, "UpdateMoneyHUD", Convert.ToString(money), "resto"); await DatabaseFunctions.UpdateMoney(user.idpj, money); return(true); }
public void XmlStoreUpdateDisconnectedTest() { var expected = "UpdatedLastname"; var id = Guid.NewGuid(); var user = new Data.Entities.User { Id = id, LastName = "New", FirstName = "FirstName " + DateTime.Now.ToString() }; UnitOfWork unit = new UnitOfWork(store); unit.UserRepository.Insert(user); unit.Save(); user = new Data.Entities.User { Id = id, LastName = expected, FirstName = "FirstName " + DateTime.Now.ToString() }; unit.UserRepository.Update(user); unit.Save(); user = unit.UserRepository.GetByID(id); Assert.IsNotNull(user); Assert.AreEqual(user.LastName, expected); }
public void XmlStoreUpdateTest() { var user = new Data.Entities.User { LastName = "Update", FirstName = "FirstName " + DateTime.Now.ToString() }; UnitOfWork unit = new UnitOfWork(store); unit.UserRepository.Insert(user); unit.Save(); unit = new UnitOfWork(store); var datauser = unit.UserRepository.GetByID(user.Id); Assert.IsNotNull(datauser); Assert.AreEqual(datauser.FirstName, user.FirstName); var firstNameUpdated = "FirstName updated"; datauser.FirstName = firstNameUpdated; unit.UserRepository.Update(datauser); unit.Save(); unit = new UnitOfWork(store); datauser = unit.UserRepository.GetByID(user.Id); Assert.IsNotNull(datauser); Assert.AreEqual(datauser.FirstName, firstNameUpdated); unit.UserRepository.Delete(user); unit.Save(); }
public async Task PaydayFunction() { await Task.Delay(1000); while (true) { await Task.Delay(3600000); foreach (var player in NAPI.Pools.GetAllPlayers()) { //var info = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (user != null) { player.TriggerEvent("hideHUD"); player.TriggerEvent("HideChat"); await Task.Delay(500); await PaydayPlayerFunction(player, user); await Task.Delay(6000); player.TriggerEvent("ShowChat"); player.TriggerEvent("showHUD"); } } } }
public async Task <ActionResult <Data.Models.User> > UpdateUser(int userId, Data.Models.UserForUpdate updatedUser) { try { Data.Entities.User dbUser = await _repository.GetUserAsync(userId); if (dbUser == null) { return(NotFound()); } _mapper.Map(updatedUser, dbUser); if (await _repository.SaveChangesAsync()) { Data.Models.User savedUser = _mapper.Map <Data.Models.User>(dbUser); return(Ok(savedUser)); } else { return(BadRequest("Failed to update.")); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Database exception: " + ex.Message)); } }
public void InMemoryStoreUpdateTest() { var user = new Data.Entities.User { LastName ="Update", FirstName = "FirstName " + DateTime.Now.ToString() }; UnitOfWork unit = new UnitOfWork(store); unit.UserRepository.Insert(user); unit.Save(); unit = new UnitOfWork(store); var datauser = unit.UserRepository.GetByID(user.Id); Assert.IsNotNull(datauser); Assert.AreEqual(datauser.FirstName, user.FirstName); var firstNameUpdated = "FirstName updated"; datauser.FirstName = firstNameUpdated; unit.UserRepository.Update(datauser); unit.Save(); unit = new UnitOfWork(store); datauser = unit.UserRepository.GetByID(user.Id); Assert.IsNotNull(datauser); Assert.AreEqual(datauser.FirstName, firstNameUpdated); unit.UserRepository.Delete(user); unit.Save(); }
public Data.Entities.User Create(Data.Entities.User user, string password, Guid currentUser) { if (String.IsNullOrWhiteSpace(password)) { throw new AppException("Password is required"); } if (_context.Users.Any(x => x.Email == user.Email)) { throw new AppException("Email " + user.Email + " is already taken"); } Guid userId = Guid.NewGuid(); byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); user.Id = userId; user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; user.CreatedBy = currentUser != Guid.Empty ? currentUser : userId; user.CreatedDate = DateTime.Now; _context.Users.Add(user); _context.SaveChanges(); return(user); }
public static void EnterCompany(Player player) { //var user = player.GetExternalData<Data.Entities.User>(0); if (!player.HasData("USER_CLASS")) { return; } Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS"); if (!user.isInCompanyInterior) { Data.Entities.Company company = user.company; user.companyInterior = company; user.lastPositionInterior = player.Position; player.Dimension = (uint)company.id; player.Position = interior; user.isInCompanyInterior = true; player.TriggerEvent("GenerateSecretaryPedCompany", company.id); return; } else { player.Dimension = 0; player.Position = user.lastPositionInterior; user.isInCompanyInterior = false; } }
public static Data.Entities.User ToEntity(this User userModel) { var user = new Data.Entities.User(); if (userModel == null) { return user; } user.UserId = userModel.UserId; user.UserName = userModel.UserName; user.DateCreated = userModel.DateCreated; user.DateModified = userModel.DateModified; user.LastActivityDate = userModel.LastActivityDate; user.IsAnonymous = userModel.IsAnonymous; return user; }
public void CacheStoreDeleteTest() { var user = new Data.Entities.User { LastName = "Delete", FirstName = "FirstName " + DateTime.Now.ToString() }; UnitOfWork unit = new UnitOfWork(store); unit.UserRepository.Insert(user); unit.Save(); unit = new UnitOfWork(store); unit.UserRepository.Delete(user.Id); unit.Save(); unit = new UnitOfWork(store); var datauser = unit.UserRepository.GetByID(user.Id); Assert.IsNull(datauser); }
public void MongoDbStoreInsertTest() { var user=new Data.Entities.User { LastName = "Insert", FirstName = "FirstName "+DateTime.Now.ToString() }; UnitOfWork unit = new UnitOfWork(store); unit.UserRepository.Insert(user); unit.Save(); unit = new UnitOfWork(store); var datauser=unit.UserRepository.GetByID(user.Id); Assert.IsNotNull(datauser); Assert.AreEqual(datauser.FirstName, user.FirstName); unit.UserRepository.Delete(user); unit.Save(); }