public async Task WhenRequestOwnerControllerUsingPostWithOwnerOnBody_AndRequestOwnerControllerUsingGet_ThenVerifyIfOwnerWasAdded_ThenRequestOwnerControllerUsingPutWithUpdatedOwnerOnBody_AndRequestOwnerControllerUsingGet_ThenVerifyIfOwnerWasUpdated() { // Arrange var owner = OwnerHelper.CreateRandomOwner(); // Act var post_response = await client.PostAsync($"{url}", new StringContent(JsonConvert.SerializeObject(owner), Encoding.UTF8, "application/json")); Assert.AreEqual(post_response.StatusCode, System.Net.HttpStatusCode.OK); var get_response = await client.GetAsync($"{url}/{owner.Id}"); Assert.AreEqual(get_response.StatusCode, System.Net.HttpStatusCode.OK); OwnerHelper.AssertOwner(owner, JsonConvert.DeserializeObject <Owner>(await get_response.Content.ReadAsStringAsync())); var updatedOwner = OwnerHelper.CreateRandomOwner(); updatedOwner.Id = owner.Id; var put_response = await client.PutAsync($"{url}/{owner.Id}", new StringContent(JsonConvert.SerializeObject(updatedOwner), Encoding.UTF8, "application/json")); Assert.AreEqual(put_response.StatusCode, System.Net.HttpStatusCode.OK); get_response = await client.GetAsync($"{url}/{owner.Id}"); Assert.AreEqual(get_response.StatusCode, System.Net.HttpStatusCode.OK); OwnerHelper.AssertOwner(updatedOwner, JsonConvert.DeserializeObject <Owner>(await get_response.Content.ReadAsStringAsync())); }
public Shortlink(ShortlinkRequest request, AkaContext context) { LinkId = AkaHelper.GetNextAvailableIDFrom(context); PrettyName = request.PrettyName; Destination = new Uri(request.DestinationUri); Owners = OwnerHelper.CreateListFrom(request.Owners); LastUpdated = DateTime.Now; }
public void BtnSiteDone() { try { DataSet.Site.GpsLocation = GPSCoords.Parse(Latitude, Longitude); DataSet.Site.Owner = Owner; OwnerHelper.Add(Owner); DataSet.Site.SiteNotes = Notes; DataSet.Site.PrimaryContact = PrimaryContact; DataSet.Site.SecondaryContact = SecondaryContact; DataSet.Site.Elevation = float.Parse(Elevation); DataSet.Site.Images = _siteImages.ToList(); var bw = new BackgroundWorker(); bw.DoWork += (o, e) => { var oldFile = DataSet.SaveLocation; var oldName = DataSet.Site.Name; DataSet.Site.Name = SiteName; DataSet.SaveToFile(false); if (SiteName.CompareTo(oldName) != 0) { File.Delete(oldFile); } }; bw.RunWorkerCompleted += (o, e) => { EventLogger.LogInfo(DataSet, GetType().ToString(), "Site saved. Site name: " + DataSet.Site.Name); CreateEditDeleteVisible = Visibility.Visible; DoneCancelVisible = Visibility.Collapsed; DoneCancelEnabled = true; SiteControlsEnabled = false; ApplicationCursor = Cursors.Arrow; if (!IsNewSite) { return; } WasCompleted = true; TryClose(); }; ApplicationCursor = Cursors.Wait; DoneCancelEnabled = false; bw.RunWorkerAsync(); } catch (Exception e) { Common.ShowMessageBox("Error", e.Message, false, true); EventLogger.LogError(DataSet, GetType().ToString(), "Tried to create site but failed. Details: " + e.Message); } }
public async Task WhenRequestOwnerControllerUsingPost_ThenICheckIfOwnerWasAdded() { // Arrange var owner = OwnerHelper.CreateRandomOwner(); client = new HttpClient(); // Act var response = await client.PostAsync($"{url}", new StringContent(JsonConvert.SerializeObject(owner), Encoding.UTF8, "application/json")); // Assert Assert.AreEqual(response.StatusCode, System.Net.HttpStatusCode.OK); }
public virtual IActionResult BceidOwnerIdGet([FromRoute] int id) { // get business string businessGuid = UserAccountHelper.GetBusinessGuid(_httpContext, _env); HetBusiness business = _context.HetBusiness.AsNoTracking() .FirstOrDefault(x => x.BceidBusinessGuid.ToLower().Trim() == businessGuid.ToLower().Trim()); if (business == null) { return(StatusCode(StatusCodes.Status401Unauthorized)); } // check access if (!CanAccessOwner(business.BusinessId, id)) { return(StatusCode(StatusCodes.Status401Unauthorized)); } return(new ObjectResult(new HetsResponse(OwnerHelper.GetRecord(id, _context, _configuration)))); }
public async Task WhenRequestOwnerControllerUsingPost_ThenVerifyIfOwnerWasCreatedUsingGetRequest_ThenISendDeleteRequestToOwnerController_ThenICantFindOwnerOnGet() { // Arrange var owner = OwnerHelper.CreateRandomOwner(); client = new HttpClient(); var insert_response = await client.PostAsync($"{url}", new StringContent(JsonConvert.SerializeObject(owner), Encoding.UTF8, "application/json")); var get_response = await client.GetAsync($"{url}/{owner.Id}"); // Act var delete_response = await client.DeleteAsync($"{url}/{owner.Id}"); get_response = await client.GetAsync($"{url}/{owner.Id}"); var test = get_response.Content.ReadAsStringAsync(); // Assert Assert.AreEqual(get_response.StatusCode, System.Net.HttpStatusCode.NoContent); }