public List <ProfileDetail> GetFriendsList() { var profileService = new ProfileServices(_userId); var foundFriends = new List <ProfileDetail>(); using (var ctx = new ApplicationDbContext()) { var userProfile = profileService.GetProfile(); foreach (var friend in userProfile.FriendsList) { var friendsProfile = profileService.GetByUsername(friend.FriendsUsername); var friendInList = new ProfileDetail { FullName = friendsProfile.FullName, Username = friendsProfile.Username, FirstName = friendsProfile.FirstName, LastName = friendsProfile.LastName, City = friendsProfile.City, State = friendsProfile.State, ZipCode = friendsProfile.ZipCode, }; foundFriends.Add(friendInList); } } return(foundFriends); }
public ActionResult DeleteConfirmed(int id) { ProfileDetail profile = db.ProfileDetails.Find(id); db.ProfileDetails.Remove(profile); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult BatchEdit(BatchEditViewModel model) { if (!ModelState.IsValid) { BatchEditViewModel batchEditViewModel = new BatchEditViewModel(); batchEditViewModel.ProfileSelectList = GetProfileSelectList(SessionHelper.CurrentUser.UserToken); batchEditViewModel.AuthList = GetAllAuthByProfileId(SessionHelper.CurrentUser.UserToken, model.ProfileId); batchEditViewModel.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(SessionHelper.CurrentUser.UserToken, model.ProfileId); return(View(batchEditViewModel)); } if (model.SubmitType == "Add") { if (model.AuthWhichIsNotIncludeList != null) { List <AuthCheckViewModel> record = model.AuthWhichIsNotIncludeList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { ProfileDetail profileDetail = new ProfileDetail(); profileDetail.AuthId = item.Id; profileDetail.ProfileId = model.ProfileId; _profileDetailService.Add(SessionHelper.CurrentUser.UserToken, profileDetail); } } } } if (model.SubmitType == "Delete") { if (model.AuthList != null) { List <AuthCheckViewModel> record = model.AuthList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { var apiResponseModel = _profileDetailService.DeleteByProfileIdAndAuthId(SessionHelper.CurrentUser.UserToken, model.ProfileId, item.Id); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { //not error } else { BatchEditViewModel batchEditViewModel = new BatchEditViewModel(); batchEditViewModel.ProfileSelectList = GetProfileSelectList(SessionHelper.CurrentUser.UserToken); batchEditViewModel.AuthList = GetAllAuthByProfileId(SessionHelper.CurrentUser.UserToken, model.ProfileId); batchEditViewModel.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(SessionHelper.CurrentUser.UserToken, model.ProfileId); ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; return(View(batchEditViewModel)); } } } } } return(RedirectToAction(nameof(ProfileDetailController.BatchEdit), new { profileId = model.ProfileId })); }
/// <summary> /// </summary> private void btnSaveProfile_Click(object sender, EventArgs e) { // save profile details var newProfile = new ProfileDetail(); newProfile.profileName = tbProfileName.Text.Trim(); newProfile.siteUrl = tbSiteUrl.Text.Trim(); newProfile.username = tbUsername.Text.Trim(); newProfile.password = tbPassword.Text.Trim(); newProfile.domain = tbDomain.Text.Trim(); newProfile.isSpOnline = cbIsSharePointOnline.Checked; if (GenUtil.IsNull(newProfile.profileName)) { MessageBox.Show("Profile name is required.", "Error"); return; } if (GenUtil.IsNull(newProfile.siteUrl)) { MessageBox.Show("Site url is required.", "Error"); return; } if (GenUtil.IsNull(newProfile.username)) { MessageBox.Show("Username is required.", "Error"); return; } if (GenUtil.IsNull(newProfile.password)) { MessageBox.Show("Password is required.", "Error"); return; } if (!cbIsSharePointOnline.Checked && GenUtil.IsNull(newProfile.domain)) { MessageBox.Show("Domain is required.", "Error"); return; } // get matching profile or create new var existingProfile = lstProfiles.FirstOrDefault(x => x.profileName.Trim().ToLower() == newProfile.profileName.Trim().ToLower()); if (existingProfile == null) { lstProfiles.Add(newProfile); LoadProfilesIntoListbox(); } else { existingProfile.profileName = newProfile.profileName; existingProfile.siteUrl = newProfile.siteUrl; existingProfile.username = newProfile.username; existingProfile.password = newProfile.password; existingProfile.domain = newProfile.domain; existingProfile.isSpOnline = newProfile.isSpOnline; } }
public ActionResult Edit([Bind(Include = "ID,UserName,Age,Location,Gender")] ProfileDetail profile) { if (ModelState.IsValid) { db.Entry(profile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(profile)); }
public ActionResult SetProfile(ProfileDetail model) { var svc = CreateProfileService(); if (svc.SetProfile(model)) { return(RedirectToAction("MyProfile")); } TempData["SaveResult"] = "There was an error changing your profile."; return(RedirectToAction("SetProfile")); }
public ProfileDetail GetProfile(Guid user) { using (var db = new ApplicationDbContext()) { var entity = db.Profiles.Single(p => p.UserID == user); var prof = new ProfileDetail { BIO = entity.BIO, Picture = entity.Picture, UserName = entity.UserName }; return(prof); } }
public int Update(ProfileDetail record) { int result = 0; using (AppDbContext dbContext = new AppDbContext()) { dbContext.Entry(record).State = EntityState.Modified; result = dbContext.SaveChanges(); } return(result); }
public int DeleteByProfileIdAndAuthId(int profileId, int authId) { int result = 0; using (AppDBContext dbContext = new AppDBContext(_config)) { ProfileDetail record = dbContext.ProfileDetail.Where(pd => pd.ProfileId == profileId && pd.AuthId == authId).AsNoTracking().SingleOrDefault(); dbContext.Entry(record).State = EntityState.Deleted; result = dbContext.SaveChanges(); } return(result); }
//SET Profile public bool SetProfile(ProfileDetail profile) { var prof = new Profile(); using (var db = new ApplicationDbContext()) { prof = db.Profiles.Single(p => p.UserID == _userId); prof.Picture = profile.Picture; prof.UserName = profile.UserName; prof.BIO = profile.BIO; return(db.SaveChanges() == 1); } }
// GET: Profiles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProfileDetail profile = db.ProfileDetails.Find(id); if (profile == null) { return(HttpNotFound()); } return(View(profile)); }
public ProfileDetail GetMyProfile() { using (var db = new ApplicationDbContext()) { var check = db.Profiles.SingleOrDefault(p => p.UserID == _userId); if (check == null) { CreateProfile(_userId); } var entity = db.Profiles.SingleOrDefault(p => p.UserID == _userId); var prof = new ProfileDetail { BIO = entity.BIO, Picture = entity.Picture, UserName = entity.UserName }; return(prof); } }
public static List <ProfileDetailValue> Generate(ProfileDetail details) { List <ProfileDetailValue> result = new List <ProfileDetailValue>(); string[] newLines = details.Description.Split('\n'); foreach (string newLine in newLines) { string[] data = newLine.Split(':'); if (data.Length == 2) { result.Add(new ProfileDetailValue(data[0], data[1])); } } return(result); }
public int Add(ProfileDetail record) { int result = 0; using (AppDBContext dbContext = new AppDBContext(_config)) { ProfileDetail existrecord = dbContext.ProfileDetail.Where(pd => pd.ProfileId == record.ProfileId && pd.AuthId == record.AuthId).FirstOrDefault(); if (existrecord == null) { dbContext.Entry(record).State = EntityState.Added; result = dbContext.SaveChanges(); } } return(result); }
// GET: Profiles/Details/5 public ActionResult Details(int?id) { //Verify if User has allowed url to be accessed while logged out //If yes: continue execution //if else: only if user has logged in can execute if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProfileDetail profile = db.ProfileDetails.Find(id); if (profile == null) { return(HttpNotFound()); } return(View(profile)); }
public ApiResponseModel <ProfileDetail> Add(string userToken, ProfileDetail profileDetail) { ApiResponseModel <ProfileDetail> result = new ApiResponseModel <ProfileDetail>(); using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); var portalApiRequestModel = new AddRequestModel(); portalApiRequestModel.UserToken = userToken; portalApiRequestModel.AuthId = profileDetail.AuthId; portalApiRequestModel.ProfileId = profileDetail.ProfileId; HttpResponseMessage response = httpClient.PostAsJsonAsync(string.Format("ProfileDetail/Add"), portalApiRequestModel).Result; result = response.Content.ReadAsAsync <ApiResponseModel <ProfileDetail> >().Result; } return(result); }
//Get By Id public ProfileDetail GetById(string id) { var entity = _context.Profiles.Find(id); if (entity == null) { return(null); } var model = new ProfileDetail { ProfileId = _userId, FirstName = entity.FirstName, LastName = entity.LastName, UserName = entity.UserName, Email = entity.Email, }; return(model); }
public ProfileDetail GetDetails(Language language) { ProfileDetail result = null; this._details.TryGetValue(language.TwoLetterIsoCode, out result); if (result != null) { return(result); } result = ProfileDetail.CreateManager().Load(this.ProfileData, language); if (result != null) { this._details.Add(language.TwoLetterIsoCode, result); return(result); } else { return(this._details["EN"]); } }
// Get by Id - Read public ProfileDetail GetProfileById(int id) { GoalService goalService = new GoalService(); using (var ctx = new ApplicationDbContext()) { var entity = ctx .Profiles .Single(e => e.ProfileId == id); var detail = new ProfileDetail { ProfileId = entity.ProfileId, FirstName = entity.FirstName, LastName = entity.LastName, Motivation = entity.Motivation, GoalsOfUser = ConvertDataEntitiesToViewModel(entity.GoalsOfUser.ToList()) }; return(detail); } }
public ProfileDetail GetByProfileIdAndAuthId(int profileId, int authId) { ProfileDetail result = null; using (AppDbContext dbContext = new AppDbContext()) { var query = from pd in dbContext.ProfileDetail join p in dbContext.Profile on pd.ProfileId equals p.Id join a in dbContext.Auth on pd.AuthId equals a.Id where p.IsDeleted == false && a.IsDeleted == false && pd.ProfileId == profileId && pd.AuthId == authId select pd; // as no tracking query = query.AsNoTracking(); result = query.SingleOrDefault(); } return(result); }
public List <ProfileDetail> GetByName(string name) { using (var ctx = new ApplicationDbContext()) { var Profiles = ctx.Profiles.Where(e => e.FirstName.Contains(name) || e.LastName.Contains(name)).ToList(); foreach (var profile in Profiles) { ICollection <Event> events = GetEvents(profile.AllVisits); var found = new ProfileDetail { Username = profile.Username, FirstName = profile.FirstName, LastName = profile.LastName, City = profile.City, State = profile.State, ZipCode = profile.ZipCode, Events = events, }; searchResults.Add(found); } return(searchResults); } }
public ProfileCache(Profile profile) : base(profile) { lock (CacheLockObject) { // SUMMARY: Adding ProfileThumbnail ProfileThumbnail profileThumbnail = ProfileThumbnail.CreateManager().Load(profile, ThumbnailIdentifier.Default).FirstOrDefault(); if (profileThumbnail != null) { ProfileThumbnailData thumbnailData = ProfileThumbnailData.LoadByProfileThumbnail(profileThumbnail, null).FirstOrDefault(); this._defaultThumbnail = thumbnailData.Data; this._thumbnailUrl = string.Format("/thumbnails/default/{0}", profile.ID); } this._id = profile.ID; this._url = string.Format("/profile/{0}", profile.ID); this._details = new Dictionary <string, ProfileDetail>(); List <ProfileDetail> profileDetails = ProfileDetail.CreateManager().Load(profile); if (profileDetails == null || profileDetails.Count == 0) { this._hasError = true; Log.Error("web.Profile:" + this._id + " does not have any ProfileDetail"); return; } foreach (ProfileDetail pd in profileDetails) { if (this._details.ContainsKey(pd.Language.TwoLetterIsoCode)) { continue; } this._details.Add(pd.Language.TwoLetterIsoCode, pd); } } }
public void Configure(ProfileDetail details) { UILabelExtensions.SetupLabelAppearance(_detailLabel, details.Description, Colors.ProfileGray, 12f); UILabelExtensions.SetupLabelAppearance(_detailValueLabel, details.Value, Colors.ProfileGrayDarker, 14f, UIFontWeight.Medium); _separatorView.BackgroundColor = Colors.ProfileGrayWhiter; }
public ApiResponseModel <ProfileDetail> Add(string userToken, string displayLanguage, ProfileDetail profileDetail) { ApiResponseModel <ProfileDetail> result = new ApiResponseModel <ProfileDetail>(); // api'yi çağırma yapılır, gelen sonuç elde edilir using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); httpClient.DefaultRequestHeaders.Add("DisplayLanguage", displayLanguage); var portalApiRequestModel = new AddRequestModel(); portalApiRequestModel.AuthId = profileDetail.AuthId; portalApiRequestModel.ProfileId = profileDetail.ProfileId; HttpResponseMessage response = httpClient.PostAsJsonAsync(string.Format("v1/ProfileDetail"), portalApiRequestModel).Result; result = response.Content.ReadAsJsonAsync <ApiResponseModel <ProfileDetail> >().Result; } return(result); }
public ActionResult BatchEdit(BatchEditViewModel model) { if (!ModelState.IsValid) { if (model.ProfileId.HasValue) { model.AuthList = GetAllAuthByProfileId(model.ProfileId.Value); model.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(model.ProfileId.Value); } else { model.AuthList = new List <AuthCheckViewModel>(); model.AuthWhichIsNotIncludeList = new List <AuthCheckViewModel>(); } return(View(model)); } if (model.SubmitType == "Add") { if (model.AuthWhichIsNotIncludeList != null) { ModelState.Clear(); List <AuthCheckViewModel> record = model.AuthWhichIsNotIncludeList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { ProfileDetail profileDetail = new ProfileDetail(); profileDetail.AuthId = item.Id; profileDetail.ProfileId = model.ProfileId.Value; _profileDetailService.Add(profileDetail); } } } } if (model.SubmitType == "Delete") { if (model.AuthList != null) { ModelState.Clear(); List <AuthCheckViewModel> record = model.AuthList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { var result = _profileDetailService.DeleteByProfileIdAndAuthId(model.ProfileId.Value, item.Id); if (result <= 0) { BatchEditViewModel batchEditViewModel = new BatchEditViewModel(); batchEditViewModel.ProfileSelectList = GetProfileSelectList(); batchEditViewModel.AuthList = GetAllAuthByProfileId(model.ProfileId.Value); batchEditViewModel.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(model.ProfileId.Value); ViewBag.ErrorMessage = "Error"; return(View(batchEditViewModel)); } } } } } model.ProfileSelectList = GetProfileSelectList(); if (model.ProfileId.HasValue) { model.AuthList = GetAllAuthByProfileId(model.ProfileId.Value); model.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(model.ProfileId.Value); } else { model.AuthList = new List <AuthCheckViewModel>(); model.AuthWhichIsNotIncludeList = new List <AuthCheckViewModel>(); } return(View(model)); }
public ActionResult BatchEdit(BatchEditViewModel model) { if (!ModelState.IsValid) { if (model.ProfileId.HasValue) { model.AuthList = GetAllAuthByProfileId(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); model.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); } else { model.AuthList = new List <AuthCheckViewModel>(); model.AuthWhichIsNotIncludeList = new List <AuthCheckViewModel>(); } return(View(model)); } if (model.SubmitType == "Add") { if (model.AuthWhichIsNotIncludeList != null) { ModelState.Clear(); List <AuthCheckViewModel> record = model.AuthWhichIsNotIncludeList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { ProfileDetail profileDetail = new ProfileDetail(); profileDetail.AuthId = item.Id; profileDetail.ProfileId = model.ProfileId.Value; _profileDetailService.Add(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, profileDetail); } } } } if (model.SubmitType == "Delete") { if (model.AuthList != null) { ModelState.Clear(); List <AuthCheckViewModel> record = model.AuthList.Where(x => x.Checked == true).ToList(); if (record != null) { foreach (var item in record) { var apiResponseModel = _profileDetailService.DeleteByProfileIdAndAuthId(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value, item.Id); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { //not error } else { BatchEditViewModel batchEditViewModel = new BatchEditViewModel(); batchEditViewModel.ProfileSelectList = GetProfileSelectList(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar); batchEditViewModel.AuthList = GetAllAuthByProfileId(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); batchEditViewModel.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList; return(View(batchEditViewModel)); } } } } } model.ProfileSelectList = GetProfileSelectList(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar); if (model.ProfileId.HasValue) { model.AuthList = GetAllAuthByProfileId(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); model.AuthWhichIsNotIncludeList = GetAllAuthByProfileIdWhichIsNotIncluded(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, model.ProfileId.Value); } else { model.AuthList = new List <AuthCheckViewModel>(); model.AuthWhichIsNotIncludeList = new List <AuthCheckViewModel>(); } return(View(model)); }
public ActionResult Index(string id, CityByState city) { var businessService = new BusinessService(); var cityService = CreateCityService(); var profileService = CreateProfileService(); //Is input a State Abreviation? bool parseResult = Enum.TryParse($"{id}", out StateName state); //Is input a State at all? if (parseResult == false) { city.StateResult = city.AbreviateState(id); } if (parseResult) { city.StateResult = state; } //Is input a City? var searchByCity = new List <CityListItem>(); if (city.StateResult == null) { searchByCity = cityService.GetCitiesByName(id); if (searchByCity.Count == 1) { return(RedirectToAction($"Details/{searchByCity[0].ID}")); } if (searchByCity.Count != 0) { return(RedirectToAction($"Search/{id}")); } } //Is inpuy a Business var searchByBusiness = new List <BusinessListItem>(); if (searchByCity.Count() == 0) { searchByBusiness = businessService.GetByName(id); if (searchByBusiness.Count == 1) { return(RedirectToAction($"Details/{searchByBusiness[0].ID}", "Business")); } if (searchByBusiness.Count != 0) { return(RedirectToAction($"Search/{id}", "Business")); } } var searchByUsername = new ProfileDetail(); if (searchByBusiness.Count() == 0) { searchByUsername = profileService.GetByUsername(id); if (searchByUsername.Username != null) { return(RedirectToAction($"Index/{searchByUsername.Username}", "Profile")); } } var searchByName = new List <ProfileDetail>(); if (searchByUsername.Username == null) { searchByName = profileService.GetByName(id); if (searchByName.Count != 0) { return(RedirectToAction($"Search/{id}", "Profile")); } } return(RedirectToAction($"State/{city.StateResult}")); }