public IHttpActionResult AddFacility(int id, [FromBody] NewFacilityDto value) { var entity = Svc.GetById(id); if (entity == null) { return(NotFound()); } var facility = value.ToEntity(); int facilityId = Svc.AddFacility(id, facility); var createdDto = new FacilityDto(); createdDto.LoadFromEntity(facility); return(CreatedAtRoute("GetFacilityById", new { id = facilityId }, createdDto)); }
protected async Task OnSubmitAsync() { try { var newFacilityDto = new NewFacilityDto { Name = Facility.Name, Address = Facility.Address }; if (Facility.Picture != null) { var imageDto = new ImageDto { Name = Facility.Picture.Name, ContentType = Facility.Picture.ContentType, Content = await Facility.Picture.GetResizedImageAsync(1000, _cancellationTokenSource.Token) }; newFacilityDto.Image = imageDto; } var result = await HttpClient.PostAsJsonAsync("/api/NewFacility", newFacilityDto); if (!result.IsSuccessStatusCode) { } else { NavigationManager.NavigateTo("dashboard"); } } catch (Exception e) { } }