public ProfileEntity?UpdatePassively(ProfileEntity profileEntity) { using var session = _mongoRepository.Client.StartSession(); session.StartTransaction(); try { var filter = Builders <ProfileEntity> .Filter.And( Builders <ProfileEntity> .Filter.Eq(p => p.AccountId, profileEntity.AccountId), Builders <ProfileEntity> .Filter.Eq(p => p.Version, profileEntity.Version - 1) ); var updateDefinition = Builders <ProfileEntity> .Update .Set("Balance", profileEntity.Balance) .Set("Version", profileEntity.Version) .Set("Approved", profileEntity.Approved) .Set("Pending", profileEntity.Pending) .Set("Blocked", profileEntity.Blocked); var result = _mongoRepository.Update(filter, updateDefinition); session.CommitTransaction(); if (result != null && !string.IsNullOrEmpty(result.Id)) { return(result); } return(null); } catch { session.AbortTransaction(); return(null); } }
private static void SaveProfileToSession(ProfileEntity userProfile) { if (HttpContext.Current.Session != null) { HttpContext.Current.Session[GetSessionKeyNameForProfile(userProfile.UserName)] = userProfile; } }
public MembershipUser CreateUser(string login, string password, string email, string firstName, string lastName, DateTime birthDate) { MembershipUser membershipUser = GetUser(login, false); if (membershipUser != null) { return(null); } var user = new UserEntity { Login = login, Password = Crypto.HashPassword(password), //http://msdn.microsoft.com/ru-ru/library/system.web.helpers.crypto(v=vs.111).aspx //CreationDate = DateTime.Now }; var profile = new ProfileEntity { FirstName = firstName, LastName = lastName, Email = email, BirthDate = birthDate }; user.RoleId = RoleService.GetRoleId("User"); UserService.CreateUser(user, profile); membershipUser = GetUser(login, false); return(membershipUser); }
public ProfileEntity SomeMethod() { // example of method returning this object ProfileEntity temp = new ProfileEntity(); return(temp); }
public bool Confirm(string code) { var entity = _unitOfWork.Repository <ConfirmationEntity>().Include(x => x.User).FirstOrDefault(x => x.Code == code); if (entity?.Confirmed == false) { entity.Confirmed = true; entity.ConfirmDate = DateTime.Now; _unitOfWork.Repository <ConfirmationEntity>().Update(entity); var profile = new ProfileEntity { Status = UserStatusEnum.ActiveCandidate, UserId = entity.User.Id, AcademicStudies = new AcademicStudiesEntity(), CandidateAdditionalData = new CandidateAdditionalDataEntity(), General = new GeneralEntity(), HighSchool = new HighSchoolEntity(), MilitaryService = new MilitaryServiceEntity(), BankInfo = new BankInfoEntity(), ScholarDetails = new ScholarDetailsEntity(), VolunteerDetails = new VolunteerDetailsEntity() }; var form = _formService.GenerateForm(entity.User.Id); _unitOfWork.Repository <ProfileEntity>().Insert(profile); return(true); } return(false); }
public async Task <ActionResult> Create( ProfileEntity obj, HttpPostedFileBase profileFile ) { CloudBlockBlob profileBlob = null; #region Upload File In Blob Storage //Step 1: Uploaded File in BLob Storage if (profileFile != null && profileFile.ContentLength != 0) { profileBlob = await blobOperations.UploadBlob(profileFile); obj.ProfilePath = profileBlob.Uri.ToString(); } //Ends Here #endregion #region Save Information in Table Storage //Step 2: Save the Infromation in the Table Storage //Get the Original File Size obj.Email = User.Identity.Name; // The Login Email obj.RowKey = obj.ProfileId.ToString(); obj.PartitionKey = obj.Email; //Save the File in the Table tableOperations.CreateEntity(obj); //Ends Here #endregion return(RedirectToAction("Index")); }
/// <summary> /// /// </summary> /// <param name="profiles"></param> /// <param name="profileCount"></param> /// <returns></returns> private ProfileEntityWithCount GetProfileEntityFromUserModel(List <Profile> profiles, int profileCount, int numberOfRowsPerPage) { ProfileEntityWithCount profileEntityWithCount = new ProfileEntityWithCount(); if (profiles.Any()) { profileEntityWithCount.profileEntities = new List <ProfileEntity>(); foreach (var profile in profiles) { var profileEntity = new ProfileEntity() { pID = profile.pID, CreatedBy = profile.CreatedBy, createdOn = profile.createdOn, UpdatedBy = profile.UpdatedBy, UpdatedOn = profile.UpdatedOn, ProfileId = profile.ProfileId, Description = profile.Description, Enabled = profile.Enabled }; profileEntityWithCount.profileEntities.Add(profileEntity); } profileEntityWithCount.profileCount = profileCount; profileEntityWithCount.numberOfRowsPerPage = numberOfRowsPerPage; return(profileEntityWithCount); } return(null); }
public async Task <ProfileEntity> UpsertProfile(ProfileEntity entity) { var profile = await GetProfile(entity.Id); if (profile == null) { _db.Add(entity); } else { profile.Name = entity.Name; profile.Age = entity.Age; profile.ShowAge = entity.ShowAge; profile.Location = entity.Location; profile.Latitude = entity.Latitude; profile.Longitude = entity.Longitude; profile.Bio = entity.Bio; profile.ContactDetails = entity.ContactDetails; profile.FavouritePosition = entity.FavouritePosition; profile.Gender = entity.Gender; profile.SearchForCategory = entity.SearchForCategory; profile.SearchRadius = entity.SearchRadius; profile.SearchMinAge = entity.SearchMinAge; profile.SearchMaxAge = entity.SearchMaxAge; profile.UpdatedAt = DateTime.UtcNow; _db.Update(profile); } await _db.SaveChangesAsync(); var updatedProfile = await GetProfile(entity.Id); return(updatedProfile); }
/// <inheritdoc/> public async Task <Profile> Create(Profile profile) { if (await this.context.Profiles.FirstOrDefaultAsync(x => x.Username.ToLower().Contains(profile.Username.ToLower())) != null) { throw new ProfileCreationException("Profile with this username already exists."); } if (await this.context.Profiles.FirstOrDefaultAsync(x => x.UserId == profile.UserId) != null) { throw new ProfileCreationException("This user already has a profile."); } var profileEntity = new ProfileEntity { UserId = profile.UserId, Username = profile.Username, Bio = profile.Bio, ImageUrl = profile.ImageUrl, DisplayName = profile.DisplayName, }; await this.context.Profiles.AddAsync(profileEntity); return(profile); }
public ProfileEntity Update(ProfileEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (entity.ProfileValue == null) { throw new ArgumentNullException("entity.PropertyValue"); } if (entity.ProfileId == 0) { throw new ArgumentNullException("entity.ProfileId"); } var original = from profile in this.m_dataContext.ProfileEntities where profile.ProfileId == entity.ProfileId select profile; original.ToList().ForEach(item => { item.ProfileValue = entity.ProfileValue; }); this.m_dataContext.SubmitChanges(); return(entity); }
private Profile CreateIntroProfile() { try { // Load the intro profile from JSON into a ProfileEntity string json = File.ReadAllText(Path.Combine(Constants.ApplicationFolder, "Resources", "intro-profile.json")); ProfileEntity profileEntity = CoreJson.DeserializeObject <ProfileEntity>(json) !; // Inject every LED on the surface into each layer foreach (LayerEntity profileEntityLayer in profileEntity.Layers) { profileEntityLayer.Leds.AddRange(_devices.SelectMany(d => d.Leds).Select(l => new LedEntity { DeviceIdentifier = l.Device.Identifier, LedName = l.RgbLed.Id.ToString() })); } Profile profile = new(new DummyModule(), profileEntity); profile.Activate(_devices); _profileService.InstantiateProfile(profile); return(profile); } catch (Exception e) { _logger.Warning(e, "Failed to load intro profile"); } return(new Profile(new DummyModule(), "Intro")); }
public async Task SaveProfile(ProfileEntity entity) { var table = await GetTable("student"); var insertOrMergeOperation = TableOperation.InsertOrReplace(entity); await table.ExecuteAsync(insertOrMergeOperation); }
public string CreateProfile(ProfileEntity profileEntity) { var errorMessage = ""; var profileCount = _unitOfWork.ProfileRepository.GetMany(a => a.ProfileId.Trim().ToUpper() == profileEntity.ProfileId.Trim().ToUpper()).ToList().Count(); if (profileCount == 0) { using (var scope = new TransactionScope()) { var profile = new Profile { CreatedBy = profileEntity.CreatedBy, createdOn = profileEntity.createdOn, ProfileId = profileEntity.ProfileId, Description = profileEntity.Description, Enabled = true }; _unitOfWork.ProfileRepository.Insert(profile); _unitOfWork.Save(); scope.Complete(); return(errorMessage); } } else { errorMessage = "Duplicate profile id not allowed."; return(errorMessage); } }
// GET: Profile public ActionResult Index() { ProfileEntity prof = userService.GetUserProfile(User.Identity.Name); ProfileModel profile = prof.ToProfileModel(); return(View(profile)); }
private Profile MapToProfile(ProfileEntity dbProfile) { if (dbProfile == null) { return(null); } var profile = new Profile { Description = dbProfile.Description, Id = dbProfile.Id, Name = dbProfile.Name, Sdp = dbProfile.Sdp, SortIndex = dbProfile.SortIndex, CreatedBy = dbProfile.CreatedBy, CreatedOn = dbProfile.CreatedOn, UpdatedBy = dbProfile.UpdatedBy, UpdatedOn = dbProfile.UpdatedOn, Groups = MapToProfileGroups(dbProfile.ProfileGroups), UserAgents = dbProfile.UserAgents == null ? new List <UserAgent>() : dbProfile.UserAgents.Select(oua => MapToUserAgent(oua.UserAgent)).ToList() }; return(profile); }
public ProfileEntity GetUserProfile(string login) { UserEntity user = uow.Users.GetByPredicate(dalUser => dalUser.Login == login).ToBllUser(); ProfileEntity profile = uow.Profiles.GetById(user.Id).ToBllProfile(); return(profile); }
public async Task <IActionResult> Edit(int id, ProfileEntity profileEntity) { if (id != profileEntity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _profileService.UpdateAsync(profileEntity); } catch (EntityValidationException e) { ModelState.AddModelError(e.PropertyName, e.Message); return(View(profileEntity)); } catch (DbUpdateConcurrencyException) { if (await _profileService.GetByIdAsync(id) == null) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(profileEntity)); }
public void ShouldNot_Create_Invalid() { var invalidProfileEntity = new ProfileEntity(); var newCreatedAccountEntity = _service.Create(invalidProfileEntity); Assert.NotNull(newCreatedAccountEntity); }
public ProfileEntity Create(ProfileEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (entity.ApplicationId == null) { throw new ArgumentNullException("entity.ApplicationId"); } if (entity.InUser == null) { throw new ArgumentNullException("entity.InUser"); } if (entity.ProfileValue == null) { throw new ArgumentNullException("entity.ProfileValue"); } entity.InDate = DateTime.Now; this.m_dataContext.ProfileEntities.InsertOnSubmit(entity); this.m_dataContext.SubmitChanges(); return(entity); }
private static float Predict(MLContext mlContext, ITransformer model, ProfileEntity userProfile) { var predictionFunction = mlContext.Model.CreatePredictionEngine <CovidSympomes, CovidSeverityPrediction>(model); var covidSymptomesSample = new CovidSympomes() { Age09 = userProfile.Age < 10? 1 : 0, Age1019 = userProfile.Age >= 10 && userProfile.Age < 20 ? 1 : 0, Age2024 = userProfile.Age >= 20 && userProfile.Age < 25 ? 1 : 0, Age2559 = userProfile.Age > 24 && userProfile.Age < 60 ? 1 : 0, Age60 = userProfile.Age > 59 ? 1 : 0, Contact = userProfile.Contact? 1 : 0, Diarrhea = userProfile.HealthState.Diarrhea? 1 : 0, Fever = userProfile.HealthState.Fever? 1 : 0, Gender = userProfile.Gender == "m"? 1 : 0, Pains = userProfile.HealthState.Pains? 1 : 0, Severity = userProfile.HealthState.Severity, DryCough = userProfile.HealthState.DryCough? 1 : 0, NasalCongestion = userProfile.HealthState.NasalCongestion? 1 : 0, None_Symptom = userProfile.HealthState.None_Symptom? 1 : 0, RunnyNose = userProfile.HealthState.RunnyNose? 1 : 0, SoreThroat = userProfile.HealthState.SoreThroat? 1 : 0, TiredNess = userProfile.HealthState.TiredNess? 1 : 0, DifficultyInBreathing = userProfile.HealthState.DifficultyInBreathing ? 1 : 0 }; var prediction = predictionFunction.Predict(covidSymptomesSample); Console.WriteLine($"**********************************************************************"); Console.WriteLine($"Predicted fare: {prediction.Severity:0.####}"); Console.WriteLine($"**********************************************************************"); return(prediction.Severity); }
private static void SaveAlbumIdToProfile(int albumId, string userName) { ProfileEntity profileEntity = ProfileController.GetProfile(userName); profileEntity.UserAlbumId = albumId; ProfileController.SaveProfile(profileEntity); }
public async Task <bool> AddUserProfile(ProfileEntity profile) { var table = GetTable(ProfilesTable, _storageConnectionString); var insertOperation = TableOperation.Insert(profile); var insertResult = await table.ExecuteAsync(insertOperation); return(insertResult.HttpStatusCode == (int)HttpStatusCode.OK); }
public async Task <bool> AddUserProfile(ProfileEntity newProfile) { TableOperation insertOperation = TableOperation.Insert(newProfile); var table = GetTable(ProfilesTable, _storageConnectionString); await table.ExecuteAsync(insertOperation); return(await Task.FromResult(true)); }
internal ProfileDescriptor(ProfileModule profileModule, ProfileEntity profileEntity) { ProfileModule = profileModule; Id = profileEntity.Id; Name = profileEntity.Name; IsLastActiveProfile = profileEntity.IsActive; }
public async Task <ProfileEntity> CreateAsync(ProfileEntity entity, CancellationToken cancellationToken = default) { var added = this._context.Profiles.Add(entity); await this._context.SaveChangesAsync(cancellationToken); return(added.Entity); }
public static DalProfile ToDalProfile(this ProfileEntity profile) { return(new DalProfile { Id = profile.Id, ImageData = profile.ImageData, ImageMimeType = profile.ImageMimeType }); }
public void OnInit() { GameLogButton.gameObject.SetActive(false); ProfileEntity pe = ProfileInfo.Instance.ProfileEntity; ProfileName.text = pe.GetField(ProfileEntity.DataField.Name) + " <sprite=0>"; Icon.sprite = IconHashmap[ProfileEntity.GetColor(pe.GetField(ProfileEntity.DataField.Color))]; ProfileInfoControl.ParseProfile(pe); }
/// <summary> /// Method to Create Entity /// </summary> /// <param name="entity"></param> public void CreateEntity(ProfileEntity entity) { CloudTable table = tableClient.GetTableReference("ProfileEntityTable"); //Create a TableOperation object used to insert Entity into Table TableOperation insertOperation = TableOperation.Insert(entity); //Execute an Insert Operation table.Execute(insertOperation); }
public static ProfileModel ToProfileModel(this ProfileEntity profileEntity) { return(new ProfileModel() { FirstName = profileEntity.FirstName, LastName = profileEntity.LastName, Email = profileEntity.Email, BirthDate = profileEntity.BirthDate, }); }
private AbstractProfileContent ConvertContent(ProfileEntity entity) { switch (entity.ContentType) { case ProfileContentType.ExportLocation: return(JsonConvert.DeserializeObject <ExportLocationProfileContent>(entity.Content) as AbstractProfileContent); default: return(null); } }
public void TestCreateProfileData() { try { var dataManager = new DataManager(); var userData = new UserData { UserID = 69, UserName = "******", FirstName = "David", LastName = "Puddy", Email = "*****@*****.**", DisplayName = "Eisenburg", PhoneNumber = "3016969696", }; ProfileEntity userResponse = new ProfileEntity { Id = 17, ResponseTypeID = 2 }; ProfileEntity userResponse2 = new ProfileEntity { Id = 12, ResponseTypeID = 1 }; ProfileEntity userResponse3 = new ProfileEntity { Id = 7, ResponseTypeID = 3 }; ProfileEntity userResponse4 = new ProfileEntity { Id = 20, ResponseTypeID = 2 }; ProfileEntity userResponse5 = new ProfileEntity { Id = 19, ResponseTypeID = 2 }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); bool hasValue = false; userRespounses.Add(userResponse); userRespounses.Add(userResponse2); userRespounses.Add(userResponse3); userRespounses.Add(userResponse4); userRespounses.Add(userResponse5); ProfileEntity matchResponse = new ProfileEntity { Id = 18, ResponseTypeID = 2 }; ProfileEntity matchResponse2 = new ProfileEntity { Id = 19, ResponseTypeID = 2 }; ProfileEntity matchResponse3 = new ProfileEntity { Id = 8, ResponseTypeID = 3 }; ProfileEntity matchResponse4 = new ProfileEntity { Id = 25, ResponseTypeID = 4 }; ProfileEntity matchResponse5 = new ProfileEntity { Id = 11, ResponseTypeID = 1 }; matchRespounses.Add(matchResponse); matchRespounses.Add(matchResponse2); matchRespounses.Add(matchResponse3); matchRespounses.Add(matchResponse4); matchRespounses.Add(matchResponse5); var userProfileData = new UserProfileData { UserData = userData, UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.AddProfile(userProfileData); } catch (FormattedEntityValidationException ex) { LogHelper.LogInformation(ex.Message); } catch (Exception exception) { LogHelper.LogError(exception); } }
public void TestUpdateProfileData() { var dataManager = new DataManager(); /* var userData = new UserData { UserID = 34, UserName = "******", FirstName = "David", LastName = "Puddy", Email = "*****@*****.**", DisplayName = "Pud6dy9", PhoneNumber = "3016969696", Password = "******" }; ProfileEntity userResponse = new ProfileEntity { Id = 8, ID = 12, QuestionID = 1 }; ProfileEntity matchResponseUpdate = new ProfileEntity { Id = 11, ID = 13, QuestionID = 2 }; ProfileEntity matchResponseNew = new ProfileEntity { Id = 27, }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponseUpdate); matchRespounses.Add(matchResponseNew); var userProfileData = new UserProfileData { UserData = userData, UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); */ /* if (data.UserData != null) { data.UserData.DisplayName = "Giddy6969"; ProfileEntity userResponse = new ProfileEntity { Id = 17, ResponseTypeID = 2 }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); ProfileEntity matchResponse = new ProfileEntity { Id = 19, ResponseTypeID = 2 }; ProfileEntity matchResponse2 = new ProfileEntity { Id = 20, ResponseTypeID = 2 }; List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponse); matchRespounses.Add(matchResponse2); var userProfileData = new UserProfileData { UserData = data.UserData, //UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); } */ var userDataPuddy = new UserProfileRequest { //UserID = 69, UserName = "******", ProfileAttributeType = ProfileAttributeTypeEnum.All }; UserProfileData match = dataManager.FetchProfile(userDataPuddy); if (match.UserData != null) { //match.UserData.DisplayName = "Giddy6969"; ProfileEntity userResponse = new ProfileEntity { Id = 17, ResponseTypeID = 2 }; ProfileEntity userResponse2 = new ProfileEntity { Id = 12, ResponseTypeID = 1 }; ProfileEntity userResponse3 = new ProfileEntity { Id = 6, ResponseTypeID = 3 }; List<ProfileEntity> userRespounses = new List<ProfileEntity>(); userRespounses.Add(userResponse); userRespounses.Add(userResponse2); userRespounses.Add(userResponse3); ProfileEntity matchResponse = new ProfileEntity { Id = 7, ResponseTypeID = 3 }; ProfileEntity matchResponse2 = new ProfileEntity { Id = 24, ResponseTypeID = 4 }; ProfileEntity matchResponse3 = new ProfileEntity { Id = 10, ResponseTypeID = 1 }; ProfileEntity matchResponse4 = new ProfileEntity { Id = 23, ResponseTypeID = 2 }; List<ProfileEntity> matchRespounses = new List<ProfileEntity>(); matchRespounses.Add(matchResponse); matchRespounses.Add(matchResponse2); matchRespounses.Add(matchResponse3); matchRespounses.Add(matchResponse4); var userProfileData = new UserProfileData { UserData = match.UserData, UserResponses = userRespounses, MatchResponses = matchRespounses }; dataManager.ModifyProfile(userProfileData); } /* ProfileEntity matchResponseNew = new ProfileEntity { Id = 3, }; ChoiceProfile choiceResponse = new ChoiceProfile { ChoiceType = ChoiceTypeEnum.Like, UserID = 34, MatchUser = new UserData { UserID = 12, UserName = "******" } }; List<ChoiceProfile> userChoices = new List<ChoiceProfile>(); userChoices.Add(choiceResponse); var userProfileData = new UserProfileData { UserData = data.UserData, UserChoices = userChoices }; dataManager.ModifyProfile(userProfileData); */ }
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) { if (context == null) { throw new ArgumentNullException("context"); } if (collection == null) { throw new ArgumentNullException("collection"); } string str = (string) context["UserName"]; bool userIsAuthenticated = (bool) context["IsAuthenticated"]; if (!string.IsNullOrEmpty(str) && (collection.Count > 0)) { string allNames = string.Empty; string allValues = string.Empty; PrepareDataForSaving(ref allNames, ref allValues, collection, userIsAuthenticated); if (allNames.Length != 0) { using (MembershipContext context2 = ModelHelper.CreateMembershipContext(this.ConnectionString)) { User user2; ProfileEntity profile; QueryHelper.ProfileAndUser user = QueryHelper.GetProfileAndUser(context2, this.ApplicationName, str); if (((user == null) || (user.User == null)) || (user.Profile == null)) { bool createIfNotExist = true; Application application = QueryHelper.GetApplication(context2, this.ApplicationName, createIfNotExist); user2 = QueryHelper.GetUser(context2, str, application); if (user2 == null) { user2 = ModelHelper.CreateUser(context2, Guid.NewGuid(), str, application.ApplicationId, !userIsAuthenticated); } profile = new ProfileEntity { UserId = user2.UserId }; context2.Profiles.Add(profile); } else { profile = user.Profile; user2 = user.User; } user2.LastActivityDate = DateTime.UtcNow; profile.LastUpdatedDate = DateTime.UtcNow; profile.PropertyNames = allNames; profile.PropertyValueStrings = allValues; profile.PropertyValueBinary = new byte[0]; context2.SaveChanges(); } } } }