public ActionResult RemovePost(int id) { try { DbLocation location = GetLocationIfExistsAndUserHasAccess(id); if (location == null) { return(RedirectToAction("Index")); } LocationsRepository locationsRepository = _unitOfWork.LocationsRepository; locationsRepository.Remove(location); TempData["AlertType"] = "success"; TempData["AlertMessage"] = "De locatie is verwijderd!"; } catch { TempData["AlertType"] = "danger"; TempData["AlertMessage"] = "Er is iets fout gelopen tijdens het verwijderen van de locatie!"; return(View()); } return(RedirectToAction("Index", "Locations")); }
public void UpdateHitsTest() { try { DbLocation dbLocation = new DbLocation(); Location location = new Location { User = new User { UserId = 1 }, Latitude = 1, Longitude = 1, LocationDescription = "Test description", LocationName = "UpdateHitsTest", Hits = 0 }; int id = dbLocation.Create(location); location.LocationId = id; dbLocation.UpdateHits(location); Location newLocation = dbLocation.FindById(id); Assert.IsTrue(location.Hits < newLocation.Hits); dbLocation.Delete(location.LocationId); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
public void CreateLocationTest() { try { DbLocation dbLocation = new DbLocation(); Location location = new Location { User = new User { UserId = 1 }, Latitude = 1, Longitude = 1, LocationDescription = "Test description", LocationName = "CreateTest" }; int id = dbLocation.Create(location); Assert.IsTrue(id > 0); dbLocation.Delete(id); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
protected void ctlLocationLookupPopupCaller_NotifyPopupResult(object sender, string action, string value) { if (action != "ok") { return; } object returnValue = new object(); if (!isMultiple) { DbLocation location = ScgDbQueryProvider.DbLocationQuery.FindByIdentity(UIHelper.ParseLong(value)); returnValue = location; NotifyPopUpReturn(new PopUpReturnArgs(PopUpReturnType.OK, returnValue)); } else { string[] listID = value.Split('|'); IList <DbLocation> list = new List <DbLocation>(); foreach (string id in listID) { DbLocation location = ScgDbQueryProvider.DbLocationQuery.FindByIdentity(UIHelper.ParseLong(id)); if (location != null) { list.Add(location); } } returnValue = list; CallOnObjectLookUpReturn(returnValue); } }
/// <summary> /// Activate this method when a login is successful to navigate to a MainPage and remove the /// Former pages for the Navigation. /// It will also update all the search filter for the app, and its crucial that they are in this /// method and not just the startup method. /// </summary> public static void SuccessfulLoginAction() { // NavPage.Navigation.PopModalAsync(); DbLocation dbLocation = new DbLocation(); StudyGroupsController sgc = new StudyGroupsController(); LocationsController lc = new LocationsController(); JobTypesController jtc = new JobTypesController(); CoursesController cc = new CoursesController(); NavPage.Navigation.InsertPageBefore(new MainPage(), NavPage.Navigation.NavigationStack.First()); NavPage.Navigation.PopToRootAsync(); if (dbLocation.GetAllLocations().Count != 0) { lc.CompareServerHash(); sgc.CompareServerHash(); jtc.CompareServerHash(); cc.CompareServerHash(); } else { cc.UpdateCoursesFromServer(); jtc.UpdateJobTypesFromServer(); sgc.UpdateStudyGroupsFromServer(); lc.UpdateLocationsFromServer(); } }
public void UpdateLocationTest() { try { DbLocation dbLocation = new DbLocation(); Location location = new Location { User = new User { UserId = 1 }, Latitude = 1, Longitude = 1, LocationDescription = "Test description", LocationName = "UpdateTest1" }; Location newLocation = location; newLocation.LocationDescription = "Test description"; newLocation.LocationName = "UpdateTest2"; int id = dbLocation.Create(location); location.LocationId = id; newLocation.LocationId = id; dbLocation.UserUpdateLocation(newLocation); string foundLocationName = dbLocation.FindById(id).LocationName; Assert.IsTrue(foundLocationName.Equals("UpdateTest2")); dbLocation.Delete(id); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
public async Task <Location> LoadLocationFromIdAsync(int id, GameVersion version, int displayLanguage, CancellationToken token) { try { string query = "SELECT loc.id, ln.name FROM pokemon_v2_location loc\n" + "LEFT JOIN\n(SELECT e.location_id AS id, COALESCE(o.name, e.name) AS name FROM pokemon_v2_locationname e\n" + "LEFT OUTER JOIN pokemon_v2_locationname o ON e.location_id = o.location_id and o.language_id = ?\n" + "WHERE e.language_id = 9\nGROUP BY e.location_id)\nAS ln ON loc.id = ln.id\n" + "LEFT JOIN pokemon_v2_region r ON r.id = loc.region_id\n" + "LEFT JOIN pokemon_v2_versiongroupregion vgr ON r.id = vgr.region_id\n" + "WHERE loc.id = ? AND vgr.version_group_id = ?"; IEnumerable <DbLocation> locations = await _connection.QueryAsync <DbLocation>(token, query, new object[] { displayLanguage, id, version.VersionGroup }); DbLocation location = locations.FirstOrDefault(); if (location == null) { return(null); } return(new Location { Id = location.Id, Name = location.Name }); } catch (Exception) { return(null); } }
protected void ctlAutoLocation_NotifyPopupResult(object sender, string action, string result) { IList <DbLocation> iListDbLocation = ScgDbQueryProvider.DbLocationQuery.FindByLocationNameID(UIHelper.ParseLong(result), LocationName); DbLocation dbLocation = new DbLocation(); long locationID = 0; if (action == "select") { dbLocation = ScgDbQueryProvider.DbLocationQuery.FindByIdentity(UIHelper.ParseLong(result)); locationID = dbLocation == null ? 0 : dbLocation.LocationID; this.BindLocationControl(locationID); } else if (action == "textchanged") { if (string.IsNullOrEmpty(result)) { ResetValue(); } else { dbLocation = ScgDbQueryProvider.DbLocationQuery.FindDbLocationByLocationCode(result); locationID = dbLocation == null ? 0 : dbLocation.LocationID; this.BindLocationControl(locationID); } } CallOnObjectLookUpReturn(locationID); }
public ActionResult PostReview(int id, LocationReviewViewModel model) { try { DbLocation location = GetLocationIfExists(id); ViewBag.Location = location; if (location == null) { return(RedirectToAction("Index", "Reviews")); } AuthenticatedUser user = (AuthenticatedUser)User; BookingsRepository bookingsRepository = _unitOfWork.BookingsRepository; IList <DbBooking> booking = bookingsRepository.GetAllByUserIdAndLocationId(user.Id, id); if (booking == null || !booking.Any()) { return(RedirectToAction("Index", "Reviews")); } if (!ModelState.IsValid) { return(View(model)); } LocationReviewsRepository locationReviewsRepository = _unitOfWork.LocationReviewsRepository; DbLocationReview review = new DbLocationReview(); review.DateTime = DateTime.Now; review.LocationId = id; review.Review = model.Review; review.UserId = user.Id; review.Title = model.Title; // We insert our review before storing the facility ratings so we have a review id locationReviewsRepository.Insert(review); review.FacilityRatings = model.FacilityRatings.Select(x => { return(new DbLocationFacilityRating { FacilityId = x.Id, Rating = MathEx.Clamp(x.Rating, 0, 1), ReviewId = review.Id }); }).ToList(); locationReviewsRepository.Update(review); TempData["AlertType"] = "success"; TempData["AlertMessage"] = "De review is succesvol toegevoegd aan de locatie."; return(RedirectToAction("Index", "Reviews")); } catch { TempData["AlertType"] = "danger"; TempData["AlertMessage"] = "Er is iets fout gelopen tijdens het verwerken van de review!"; return(View(model)); } }
public void SetValue(long locationId) { DbLocation locate = ScgDbQueryProvider.DbLocationQuery.FindByIdentity(locationId); ctlLocationName.Value = locate.LocationName; ctlLocationID.Value = locate.LocationID.ToString(); ctlDescription.Text = locate.LocationName; ctlLocationTextBoxAutoComplete.LocationID = locate.LocationID; ctlLocationTextBoxAutoComplete.LocationName = locate.LocationName; ctlLocationTextBoxAutoComplete.LocationCode = locate.LocationCode; }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var location = new DbLocation { CompanyCode = request.CompanyCode, LocationCode = request.LocationCode, RowVersion = request.RowVersion }; _context.Set <DbLocation>().Attach(location); _context.Set <DbLocation>().Remove(location); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
private string CreateLocalHash() { DbLocation db = new DbLocation(); List <Location> locations = db.GetAllLocations(); StringBuilder sb = new StringBuilder(); foreach (var loc in locations) { sb.Append(Hasher.Base64Decode(loc.id)); } return(Hasher.CalculateMd5Hash(sb.ToString())); }
public MongoDbConfiguration(string databaseName, DbLocation databaseLocation, string connectionString, int azureDatabaseInitialThroughput = 2000, int azureDatabaseManagementPort = 443) { DatabaseName = databaseName; DatabaseLocation = databaseLocation; ConnectionString = connectionString; AzureDatabaseInitialThroughput = azureDatabaseInitialThroughput; AzureDatabaseManagementPort = azureDatabaseManagementPort; }
protected void ctlLocationLookup_OnNotifyPopup(object sender, PopUpReturnArgs args) { if (args.Type.Equals(PopUpReturnType.OK)) { DbLocation Location = (DbLocation)args.Data; ctlLocation.Text = Location.LocationCode; ctlLocationId.Value = Location.LocationID.ToString(); CallOnObjectLookUpReturn(Location); } UpdatePanelLocation.Update(); }
public void GetListOfLocationsRatedByUser() { try { DbLocation dbLocation = new DbLocation(); List <Location> list = dbLocation.LocationsByCommentUserName("Aksel"); Assert.IsTrue(list.Count > 0); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
public void ReadLocationTest() { try { DbLocation dbLocation = new DbLocation(); Location location = dbLocation.FindById(10); Assert.IsNotNull(location); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
public ActionResult Remove(int?id) { DbLocation location = GetLocationIfExistsAndUserHasAccess(id); if (location == null) { return(RedirectToAction("Index")); } ViewBag.Location = location; return(View()); }
protected void ctlLlocationLookup_OnNotifyPopup(object sender, PopUpReturnArgs args) { if (args.Type.Equals(PopUpReturnType.OK)) { DbLocation location = (DbLocation)args.Data; LocationID = location.LocationID; LocationName = location.LocationName; ctlLocationTextBoxAutoComplete.LocationID = location.LocationID; ctlLocationTextBoxAutoComplete.LocationCode = location.LocationCode.Trim(); ctlLocationTextBoxAutoComplete.LocationName = location.LocationName.Trim(); ctlDescription.Text = location.LocationName.Trim(); CallOnObjectLookUpReturn(location); } ctlUpdatePanelLocation.Update(); }
public ActionResult Edit(int?id) { DbLocation location = GetLocationIfExistsAndUserHasAccess(id); if (location == null) { return(RedirectToAction("Index")); } ViewBag.Location = location; ViewBag.LocationId = location.Id; LocationEditViewModel locationModel = location.ToLocationEditValidationModel(); return(View(locationModel)); }
private DbLocation GetLocationIfExistsAndUserHasAccess(int?id) { DbLocation location = GetLocationIfExists(id); if (location == null) { return(null); } if (location.CreatedByUserId != ((AuthenticatedUser)User).Id) { return(null); } return(location); }
protected void ctlAdd_Click(object sender, ImageClickEventArgs e) { DbLocation location = new DbLocation(); if (Mode.Equals(FlagEnum.EditFlag)) { location.LocationID = LocationID; } DbCompany com = ScgDbQueryProvider.DbCompanyQuery.FindByIdentity(CompanyID); location.LocationName = ctlDescription.Text; location.Active = ctlActive.Checked; //location.CompanyCode = com; location.CompanyID = com; location.CreBy = UserAccount.UserID; location.CreDate = DateTime.Now; location.LocationCode = ctlLocationCode.Text; location.UpdBy = UserAccount.UserID; location.UpdDate = DateTime.Now; location.IsAllowImportExpense = ctlCheckBoxAllowImportExpense.Checked; location.UpdPgm = UserAccount.CurrentProgramCode; if (UIHelper.ParseLong(ctlDefaultPBDropdown.SelectedValue) > 0) { location.DefaultPBID = UIHelper.ParseLong(ctlDefaultPBDropdown.SelectedValue); } try { // save or update currency if (Mode.Equals(FlagEnum.EditFlag)) { DbLocationService.UpdateLocation(location); DbLocationService.UpdateLocationToExp(location); } else { long locationId = DbLocationService.AddNewLocation(location); location.LocationID = locationId; } Notify_Ok(sender, e); } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); } }
/// <summary> /// Gets all Locations from the servers REST Api. /// </summary> public async Task UpdateLocationsFromServer() { DbLocation db = new DbLocation(); System.Diagnostics.Debug.WriteLine("LocationsController - UpdateLocationsFromServer: initiated"); DbStudent dbStudent = new DbStudent(); string accessToken = dbStudent.GetStudentAccessToken(); if (accessToken == null) { Authenticater.Authorized = false; return; } Uri url = new Uri(Adress); System.Diagnostics.Debug.WriteLine("LocationsController - url " + url.ToString()); var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", accessToken); try { var response = await client.GetAsync(url); if (response.StatusCode == HttpStatusCode.OK) { System.Diagnostics.Debug.WriteLine("UpdateLocationsFromServer response " + response.StatusCode.ToString()); var newLocations = await response.Content.ReadAsAsync <IEnumerable <Location> >(); db.DeleteAllLocations(); db.InsertLocations(newLocations); } if (response.StatusCode == HttpStatusCode.Unauthorized) { Authenticater.Authorized = false; } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("LocationsController - UpdateLocationsFromServer: await client.GetAsync(\"url\") Failed"); System.Diagnostics.Debug.WriteLine("LocationsController - UpdateLocationsFromServer: Exception msg: " + e.Message); System.Diagnostics.Debug.WriteLine("LocationsController - UpdateLocationsFromServer: Stack Trace: \n" + e.StackTrace); System.Diagnostics.Debug.WriteLine("LocationsController - UpdateLocationsFromServer: End Of Stack Trace"); } }
public void ReadAllLocationsTest() { try { DbLocation dbLocation = new DbLocation(); List <Location> locations = dbLocation.FindAll(); Assert.IsTrue(locations.Count > 0); } catch (FaultException <NoLocationsInDatabaseException> ) { Assert.Fail(); } catch (FaultException <System.Exception> ) { Assert.Fail(); } }
public ActionResult EditPost(int id, LocationEditViewModel model) { try { DbLocation location = GetLocationIfExistsAndUserHasAccess(id); if (location == null) { return(RedirectToAction("Index")); } if (!ModelState.IsValid) { return(View(model)); } if (location == null) { return(RedirectToAction("Index", "Home")); } LocationsRepository locationsRepository = _unitOfWork.LocationsRepository; location.Name = model.Name; location.Description = model.Description; location.Organisation = model.Organisation; location.PricePerDay = model.PricePerDay; location.Capacity = model.Capacity; location.AddressCity = model.AddressCity; location.AddressNumber = model.AddressNumber; location.AddressPostalCode = model.AddressPostalCode; location.AddressProvince = model.AddressProvince; location.AddressStreet = model.AddressStreet; locationsRepository.Update(location); TempData["AlertType"] = "success"; TempData["AlertMessage"] = "De aanpassingen zijn correct opgeslagen."; return(RedirectToAction("Edit", new { id = id })); } catch { TempData["AlertType"] = "danger"; TempData["AlertMessage"] = "Er is iets fout gelopen tijdens het verwerken van de aanpassingen!"; return(View(model)); } }
public ActionResult GetReview(int id) { DbLocation location = GetLocationIfExists(id); ViewBag.Location = location; if (location == null) { return(RedirectToAction("Index", "Reviews")); } if (!IsUserAllowedToWriteReviewForLocation(id)) { return(RedirectToAction("Index", "Reviews")); } return(View()); }
private DbLocation GetLocationIfExists(int?id) { if (id == null) { return(null); } var locationsRepository = _unitOfWork.LocationsRepository; DbLocation location = locationsRepository.Get((int)id); if (location == null) { return(null); } return(location); }
private bool DoesLocationExist(int?id) { if (id == null) { return(false); } var locationsRepository = _unitOfWork.LocationsRepository; DbLocation location = locationsRepository.Get((int)id); if (location == null) { return(false); } return(true); }
public void BindLocationControl(long locationId) { DbLocation locate = ScgDbQueryProvider.DbLocationQuery.FindByIdentity(locationId); if (locate != null) { ctlLocationTextBoxAutoComplete.LocationID = locate.LocationID; ctlLocationTextBoxAutoComplete.LocationCode = locate.LocationCode; ctlLocationTextBoxAutoComplete.LocationName = locate.LocationName; ctlDescription.Text = locate.LocationName; ctlLocationID.Value = locate.LocationID.ToString(); } else { this.ResetValue(); } ctlUpdatePanelLocation.Update(); }
private async void GetAllFilters(object sender, EventArgs e) { DbLocation lc = new DbLocation(); DbCourse cc = new DbCourse(); DbStudyGroup sgc = new DbStudyGroup(); DbJobType jtc = new DbJobType(); List <Location> locationsFilter = lc.GetAllLocations(); List <Course> coursesFilter = cc.GetAllCourses(); List <StudyGroup> studyGroupsFilter = sgc.GetAllStudyGroups(); List <JobType> jobTypesJobFilter = jtc.GetJobTypeFilterJob(); List <JobType> jobTypesProjectFilter = jtc.GetJobTypeFilterProject(); System.Diagnostics.Debug.WriteLine("GetAllFilters: locationsFilter.Count: " + locationsFilter.Count); System.Diagnostics.Debug.WriteLine("GetAllFilters: coursesFilter.Count: " + coursesFilter.Count); System.Diagnostics.Debug.WriteLine("GetAllFilters: studyGroupsFilter.Count: " + studyGroupsFilter.Count); System.Diagnostics.Debug.WriteLine("GetAllFilters: jobTypesJobFilter.Count: " + jobTypesJobFilter.Count); System.Diagnostics.Debug.WriteLine("GetAllFilters: jobTypesProjectFilter.Count: " + jobTypesProjectFilter.Count); }
public static ApiLocation ToApiEntity(this DbLocation entity) { if (entity == null) { return(null); } var mappedEntity = new ApiLocation(); mappedEntity.AddressNumber = entity.AddressNumber; mappedEntity.AddressPostalCode = entity.AddressPostalCode; mappedEntity.AddressCity = entity.AddressCity; mappedEntity.AddressProvince = entity.AddressProvince; mappedEntity.AddressStreet = entity.AddressStreet; mappedEntity.Description = entity.Description; mappedEntity.Name = entity.Name; mappedEntity.PricePerDay = entity.PricePerDay; mappedEntity.Capacity = entity.Capacity; return(mappedEntity); }