Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/IntroducingConnectionWit…
Browse files Browse the repository at this point in the history
…hWebAPI' into feature/IntroducingConnectionWithWebAPI
  • Loading branch information
agustinh2000 committed Nov 24, 2020
2 parents 489ea47 + 8ab2d3b commit 2c6eeb7
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 67 deletions.
6 changes: 3 additions & 3 deletions Uru_NaturalBooking/WebApi/Controllers/LodgingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public IActionResult Get()
}
}

[HttpGet("{id}", Name = "getLodging")]
[HttpGet("{id}", Name = "lodging")]
public IActionResult Get(Guid id)
{
try
Expand All @@ -66,7 +66,7 @@ public IActionResult Post([FromBody] LodgingModelForRequest lodgingModel)
try
{
Lodging lodging = lodgingManagement.Create(LodgingModelForRequest.ToEntity(lodgingModel), lodgingModel.TouristSpotId, lodgingModel.Images);
return CreatedAtRoute("getLodging", new { id = lodging.Id }, LodgingModelForSearchResponse.ToModel(lodging));
return CreatedAtRoute("lodging", new { id = lodging.Id }, LodgingModelForSearchResponse.ToModel(lodging));
}
catch (DomainBusinessLogicException e)
{
Expand All @@ -89,7 +89,7 @@ public IActionResult Put(Guid id, [FromBody] LodgingModelForRequest lodgingModel
try
{
Lodging lodging = lodgingManagement.UpdateLodging(id, LodgingModelForRequest.ToEntity(lodgingModel));
return CreatedAtRoute("getLodging", new { id = lodging.Id }, LodgingModelForResponse.ToModel(lodging));
return CreatedAtRoute("lodging", new { id = lodging.Id }, LodgingModelForResponse.ToModel(lodging));
}
catch (DomainBusinessLogicException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export class LodgingNotExistGuard implements CanActivate {
| boolean
| UrlTree {
this.idLodging = route.queryParams.LodgingId;
/*if (!this.lodgingService.isValidLodging(this.idLodging)) {
alert('Error. El hospedaje buscado no existe.');
this.router.navigate(['regions']);
return false;
}
return true;
*/
return true;
return new Observable<boolean | UrlTree>((obs) => {
this.lodgingService.getLodgingById(this.idLodging).subscribe(
(res) => {
obs.next(true);
},
(err) => {
alert(err.error);
obs.next(false);
this.router.navigate(['/regions']);
}
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ h1 {
border-radius: 8px;
}

.input-urlPhoto {
position: relative;
width: 50%;
top: -15vh;
}

.buttonAddPicture {
position: relative;
top: -16vh;
left: 4%;
border: none;
width: 40%;
color: white;
font-size: 135%;
background: #50c438;
padding: 1.5% 3%;
border-radius: 5px;
cursor: pointer;
}

.buttonAddPicture:hover {
background: #49a320;
}

.input-contenedor {
margin-bottom: 3.5%;
Expand All @@ -39,7 +62,7 @@ h1 {

.button {
position: relative;
top: 0;
top: -14vh;
border: none;
width: 100%;
color: white;
Expand Down Expand Up @@ -75,7 +98,7 @@ p {
@media(min-width:768px) {
.formulario {
margin: auto;
height: 160vh;
height: 125vh;
width: 40%;
margin-top: 4%;
border-radius: 2%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ <h6 class="textNoAvailable"> Disponible </h6>
<mat-error *ngIf="formGroup.controls.images.invalid">{{getErrorMessageForPhoto()}}</mat-error>
</mat-form-field>

<button type = "button" class = "buttonAddPicture" (click)="addPhoto()">Añadir foto</button>
<button type="button" class="buttonAddPicture" (click)="addPhoto()">Añadir foto</button>

<button class="button" (click)="create()" [disabled]="formGroup.invalid || isEmptyListOfPhotos()">Crear hospedaje</button>
<button class="button" (click)="create()" [disabled]="formGroup.invalid || isEmptyListOfPhotos()">Crear
hospedaje</button>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { LodgingModelForRequest } from '../../models/LodgingModelForRequest';
import { LodgingService } from '../services/lodging.service';
import { TouristSpotService } from '../services/tourist-spot.service';
import { TouristSpotModelForLodgingResponseModel } from '../../models/TouristSpotModelForLodgingResponseModel';
import { Router } from '@angular/router';

@Component({
selector: 'app-add-lodging',
templateUrl: './add-lodging.component.html',
styleUrls: ['./add-lodging.component.css'],
})
export class AddLodgingComponent implements OnInit {

informationOfLodgingToCreate: LodgingModelForRequest;

public formGroup: FormGroup;
Expand All @@ -36,11 +36,11 @@ export class AddLodgingComponent implements OnInit {

public photosOfLodging;


constructor(
private formBuilder: FormBuilder,
private lodgingServicePassed: LodgingService,
private touristSpotServicePassed: TouristSpotService
private touristSpotServicePassed: TouristSpotService,
private router: Router
) {
this.touristSpotExisting = new Array();
this.photosOfLodging = new Array();
Expand All @@ -62,7 +62,7 @@ export class AddLodgingComponent implements OnInit {

private chargeTouristSpots(): void {
this.touristSpotService.getAllTouristSpots().subscribe(
res => {
(res) => {
this.touristSpotExisting = res;
},
(err) => {
Expand All @@ -82,10 +82,17 @@ export class AddLodgingComponent implements OnInit {
this.createLodging(this.informationOfLodgingToCreate);
}

private createLodging(informationOfLodging: LodgingModelForRequest): void{
private createLodging(informationOfLodging: LodgingModelForRequest): void {
this.lodgingService.add(informationOfLodging).subscribe(
res => {
alert('Hospedaje agregado');
(res) => {
alert(
'Hospedaje con nombre: ' +
res.name +
'en la dirección' +
res.address +
' agregado correctamente'
);
this.router.navigateByUrl('/regions');
},
(err) => {
alert(err.error);
Expand All @@ -99,7 +106,7 @@ export class AddLodgingComponent implements OnInit {

public addPhoto(): void {
const path = this.formGroup.controls.images.value;
if (path.trim() !== ''){
if (path.trim() !== '') {
this.photosOfLodging.push(path);
this.formGroup.controls.images.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ mat-error {

input[type=text] {
outline: 0
}

.button[disabled] {
background-color: rgb(170, 170, 170);
cursor: not-allowed
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ <h1>Busqueda de hospedajes en {{nameOfTouristSpot}}</h1>
</div>

<ng-container *ngIf="!showLodgingsAvailables; else ButtonCancel">
<button class="button" (click)="searchOfLodgings()"> Buscar hospedajes </button>
<button [disabled]="formGroup.invalid || isInvalidQuantityOfGuest()" class="button"
(click)="searchOfLodgings()"> Buscar hospedajes </button>
</ng-container>

<ng-template #ButtonCancel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ export class CreateReserveComponent implements OnInit {
}

ngOnInit(): void {
this.lodgingForReserve = this.lodgingsService.getLodgingById(
this.lodgingId
this.lodgingsService.getLodgingById(this.lodgingId).subscribe(
(res: LodgingModelForResponse) => {
this.lodgingForReserve = res;
},
(err) => {
alert(err.error);
}
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
width: 800px;
word-wrap: break-word;
margin: auto;
text-align: center;
font-family: arial;
margin-top: 2%;
height: 300px;
height: 400px;
border-radius: 13px
}

Expand All @@ -22,21 +21,21 @@
height: auto;
background-color: #fff;
border-radius: 13px;
margin-top: 3vh
margin-top: 3vh;
}

.name {
color: #3f51b5;
position: absolute;
bottom: 80%;
bottom: 85%;
left: 40%;
font-weight: 700
}

.address {
color: grey;
position: absolute;
bottom: 60%;
bottom: 70%;
left: 40%;
margin-top: .5%
}
Expand All @@ -51,16 +50,16 @@
.pricePerNight {
color: grey;
position: absolute;
top: 17vh;
left: 40%;
bottom: 60%;
font-weight: 700
}

.review {
background-color: #252850;
position: relative;
left: 102vh;
top: -51vh;
left: 92%;
bottom: 115%;
font-weight: 700;
width: 50px;
min-height: 50px;
Expand All @@ -83,7 +82,7 @@
display: flex;
flex-direction: row;
flex-wrap: wrap;
top: -40vh;
bottom: 98%;
margin-top: 1px;
width: 40%;
left: 40%;
Expand All @@ -93,7 +92,7 @@
.image {
position: relative;
width: 300px;
height: 300px;
height: 400px;
border-radius: 13px
}

Expand All @@ -108,14 +107,21 @@
position: absolute;
left: 40%;
font-weight: 700;
top: 20vh;
bottom: 50%;
margin-top: 1%
}

.description {
position: relative;
left: 40%;
bottom: 81%;
width: 60%
}

.right {
position: absolute;
bottom: 0;
right: 64%;
right: 62%;
outline: 0;
cursor: pointer;
width: 3rem;
Expand All @@ -136,7 +142,7 @@
font-size: 39px;
margin: auto;
position: absolute;
top: 50%;
top: 48%;
left: 0;
cursor: pointer;
width: 3rem;
Expand All @@ -148,7 +154,10 @@
margin: auto;
position: absolute;
cursor: pointer;
top: 48%
top: 48%;
left: 0;
width: 3rem;
height: 3rem
}

.starReview {
Expand All @@ -167,9 +176,19 @@
}

.reserveButton {
border: none;
width: 25%;
position: absolute;
top: 45vh;
left: 60%;
background-color: #0d0d50;
color: #fff
bottom: 5%;
left: 55%;
font-size: 100%;
background: #1a2537;
padding: 1% 2%;
color: #fff;
border-radius: 5px;
cursor: pointer
}

.reserveButton:hover {
background: #5f9ea0
}
Loading

0 comments on commit 2c6eeb7

Please sign in to comment.