Compare commits
2 Commits
5c22d34125
...
7a6acd24ac
Author | SHA1 | Date | |
---|---|---|---|
7a6acd24ac | |||
dbd21a699f |
2
.gitignore
vendored
2
.gitignore
vendored
@ -491,3 +491,5 @@ fabric.properties
|
|||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
|
||||||
|
FichaBackend/appsettings.Development.json
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FichaBackend.Models.DTO;
|
using FichaBackend.Models;
|
||||||
|
using FichaBackend.Models.DTO;
|
||||||
using FichaBackend.Services;
|
using FichaBackend.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public class AdminController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавляет гида
|
/// Добавляем гида
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="guideDto"></param>
|
/// <param name="guideDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -43,6 +44,30 @@ public class AdminController : ControllerBase
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавляет достопримечательности
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="attractionDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("AddAttraction")]
|
||||||
|
public async Task<ActionResult> AddAttraction(AttractionDto attractionDto)
|
||||||
|
{
|
||||||
|
await _adminService.AddAttraction(attractionDto);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавляет отель
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hotelDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("AddHotel")]
|
||||||
|
public async Task<ActionResult> AddHotel(HotelDto hotelDto)
|
||||||
|
{
|
||||||
|
await _adminService.AddHotel(hotelDto);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -45,7 +45,33 @@ public class MainController : ControllerBase
|
|||||||
if (!_publicDataService.CityExsist(cityName))
|
if (!_publicDataService.CityExsist(cityName))
|
||||||
return BadRequest("City does not exsist");
|
return BadRequest("City does not exsist");
|
||||||
|
|
||||||
return Ok(await _publicDataService.GetAllFilmsInCity(cityName));
|
return Ok(await _publicDataService.GetAllFilms(cityName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получаем все отели в городе
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("GetAllHotelsInCity/{cityName}")]
|
||||||
|
public async Task<ActionResult<IEnumerable<HotelDto>>> GetAllHotelsInCity(string cityName)
|
||||||
|
{
|
||||||
|
if (!_publicDataService.CityExsist(cityName))
|
||||||
|
return BadRequest("City does not exsist");
|
||||||
|
|
||||||
|
return Ok(await _publicDataService.GetAllHotels(cityName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получаем все достопримечательности в городе
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("GetAllAttractionsInCity/{cityName}")]
|
||||||
|
public async Task<ActionResult<IEnumerable<AttractionDto>>> GetAllAttractionsInCity(string cityName)
|
||||||
|
{
|
||||||
|
if (!_publicDataService.CityExsist(cityName))
|
||||||
|
return BadRequest("City does not exsist");
|
||||||
|
|
||||||
|
return Ok(await _publicDataService.GetAllAttractions(cityName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -10,6 +10,8 @@ namespace FichaBackend
|
|||||||
public DbSet<CardQuestion> CardQuestions { get; set; } = null!;
|
public DbSet<CardQuestion> CardQuestions { get; set; } = null!;
|
||||||
public DbSet<Museum> Museums { get; set; } = null!;
|
public DbSet<Museum> Museums { get; set; } = null!;
|
||||||
public DbSet<Guide> Guides { get; set; } = null!;
|
public DbSet<Guide> Guides { get; set; } = null!;
|
||||||
|
public DbSet<Attraction> Attractions { get; set; } = null!;
|
||||||
|
public DbSet<Hotel> Hotels { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
125
FichaBackend/Migrations/20230825061202_Initial.Designer.cs
generated
Normal file
125
FichaBackend/Migrations/20230825061202_Initial.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using FichaBackend;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230825061202_Initial")]
|
||||||
|
partial class Initial
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.CardQuestion", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Question")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CardQuestions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Cities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cinema")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("FilmName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<string>("Time")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Films");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
87
FichaBackend/Migrations/20230825061202_Initial.cs
Normal file
87
FichaBackend/Migrations/20230825061202_Initial.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Initial : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "CardQuestions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Question = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageURL = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_CardQuestions", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Cities",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageURL = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Cities", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Films",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
CityId = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
Cinema = table.Column<string>(type: "text", nullable: false),
|
||||||
|
FilmName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageURL = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Url = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Genre = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Time = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Price = table.Column<float>(type: "real", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Films", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Films_Cities_CityId",
|
||||||
|
column: x => x.CityId,
|
||||||
|
principalTable: "Cities",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Films_CityId",
|
||||||
|
table: "Films",
|
||||||
|
column: "CityId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "CardQuestions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Films");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Cities");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
212
FichaBackend/Migrations/20230825132916_new.Designer.cs
generated
Normal file
212
FichaBackend/Migrations/20230825132916_new.Designer.cs
generated
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FichaBackend;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230825132916_new")]
|
||||||
|
partial class @new
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.CardQuestion", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Question")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CardQuestions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long?>("GuideId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GuideId");
|
||||||
|
|
||||||
|
b.ToTable("Cities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cinema")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("FilmName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<string>("Time")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Films");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ContactUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Rating")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Guides");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<double>("Latitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<double>("Longtitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float?>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Museums");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.Guide", null)
|
||||||
|
.WithMany("City")
|
||||||
|
.HasForeignKey("GuideId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
FichaBackend/Migrations/20230825132916_new.cs
Normal file
99
FichaBackend/Migrations/20230825132916_new.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class @new : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<long>(
|
||||||
|
name: "GuideId",
|
||||||
|
table: "Cities",
|
||||||
|
type: "bigint",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Guides",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
FullName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ContactUrl = table.Column<string>(type: "text", nullable: true),
|
||||||
|
Rating = table.Column<float>(type: "real", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Guides", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Museums",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
CityId = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Longtitude = table.Column<double>(type: "double precision", nullable: false),
|
||||||
|
Latitude = table.Column<double>(type: "double precision", nullable: false),
|
||||||
|
Price = table.Column<float>(type: "real", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Museums", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Museums_Cities_CityId",
|
||||||
|
column: x => x.CityId,
|
||||||
|
principalTable: "Cities",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Cities_GuideId",
|
||||||
|
table: "Cities",
|
||||||
|
column: "GuideId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Museums_CityId",
|
||||||
|
table: "Museums",
|
||||||
|
column: "CityId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Cities_Guides_GuideId",
|
||||||
|
table: "Cities",
|
||||||
|
column: "GuideId",
|
||||||
|
principalTable: "Guides",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Cities_Guides_GuideId",
|
||||||
|
table: "Cities");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Guides");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Museums");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Cities_GuideId",
|
||||||
|
table: "Cities");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GuideId",
|
||||||
|
table: "Cities");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
215
FichaBackend/Migrations/20230825144307_AddAddress.Designer.cs
generated
Normal file
215
FichaBackend/Migrations/20230825144307_AddAddress.Designer.cs
generated
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FichaBackend;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230825144307_AddAddress")]
|
||||||
|
partial class AddAddress
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.CardQuestion", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Question")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CardQuestions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long?>("GuideId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GuideId");
|
||||||
|
|
||||||
|
b.ToTable("Cities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cinema")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("FilmName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<string>("Time")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Films");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ContactUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Rating")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Guides");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<double>("Latitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<double>("Longtitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float?>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Museums");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.Guide", null)
|
||||||
|
.WithMany("City")
|
||||||
|
.HasForeignKey("GuideId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
FichaBackend/Migrations/20230825144307_AddAddress.cs
Normal file
28
FichaBackend/Migrations/20230825144307_AddAddress.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddAddress : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Address",
|
||||||
|
table: "Museums",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Address",
|
||||||
|
table: "Museums");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
276
FichaBackend/Migrations/20230826102623_AddedAttractionAndHotels.Designer.cs
generated
Normal file
276
FichaBackend/Migrations/20230826102623_AddedAttractionAndHotels.Designer.cs
generated
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FichaBackend;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230826102623_AddedAttractionAndHotels")]
|
||||||
|
partial class AddedAttractionAndHotels
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Attraction", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("City")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Attractions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.CardQuestion", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Question")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CardQuestions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long?>("GuideId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GuideId");
|
||||||
|
|
||||||
|
b.ToTable("Cities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cinema")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("FilmName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<string>("Time")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Films");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ContactUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Rating")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Guides");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Hotel", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("City")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Hotels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<double>("Latitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<double>("Longtitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float?>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Museums");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.Guide", null)
|
||||||
|
.WithMany("City")
|
||||||
|
.HasForeignKey("GuideId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddedAttractionAndHotels : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Attractions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
City = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Address = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageURL = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Attractions", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Hotels",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
City = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Price = table.Column<float>(type: "real", nullable: false),
|
||||||
|
Address = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ImageURL = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Hotels", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Attractions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Hotels");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
273
FichaBackend/Migrations/DatabaseContextModelSnapshot.cs
Normal file
273
FichaBackend/Migrations/DatabaseContextModelSnapshot.cs
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FichaBackend;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FichaBackend.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
partial class DatabaseContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Attraction", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("City")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Attractions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.CardQuestion", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Question")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CardQuestions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long?>("GuideId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("GuideId");
|
||||||
|
|
||||||
|
b.ToTable("Cities");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cinema")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("FilmName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Genre")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<string>("Time")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Films");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ContactUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FullName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Rating")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Guides");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Hotel", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("City")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ImageURL")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Hotels");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long>("CityId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<double>("Latitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<double>("Longtitude")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<float?>("Price")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CityId");
|
||||||
|
|
||||||
|
b.ToTable("Museums");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.City", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.Guide", null)
|
||||||
|
.WithMany("City")
|
||||||
|
.HasForeignKey("GuideId");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Film", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Museum", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FichaBackend.Models.City", "City")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CityId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FichaBackend.Models.Guide", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("City");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
FichaBackend/Models/Attraction.cs
Normal file
13
FichaBackend/Models/Attraction.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace FichaBackend.Models;
|
||||||
|
|
||||||
|
public class Attraction
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ImageURL { get; set; }
|
||||||
|
}
|
9
FichaBackend/Models/DTO/AttractionDto.cs
Normal file
9
FichaBackend/Models/DTO/AttractionDto.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace FichaBackend.Models;
|
||||||
|
|
||||||
|
public class AttractionDto
|
||||||
|
{
|
||||||
|
public string City { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ImageURL { get; set; }
|
||||||
|
}
|
10
FichaBackend/Models/DTO/HotelDto.cs
Normal file
10
FichaBackend/Models/DTO/HotelDto.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace FichaBackend.Models;
|
||||||
|
|
||||||
|
public class HotelDto
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
public float Price { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ImageURL { get; set; }
|
||||||
|
}
|
14
FichaBackend/Models/Hotel.cs
Normal file
14
FichaBackend/Models/Hotel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace FichaBackend.Models;
|
||||||
|
|
||||||
|
public class Hotel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public long Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
public float Price { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string ImageURL { get; set; }
|
||||||
|
}
|
@ -9,6 +9,8 @@ public interface IAdminService
|
|||||||
{
|
{
|
||||||
public Task AddMuseum(MuseumDto museumDto);
|
public Task AddMuseum(MuseumDto museumDto);
|
||||||
public Task<string> AddGuidePerson(GuideDto guideDto);
|
public Task<string> AddGuidePerson(GuideDto guideDto);
|
||||||
|
public Task<string> AddHotel(HotelDto hotelDto);
|
||||||
|
public Task<string> AddAttraction(AttractionDto attractionDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AdminService : IAdminService
|
public class AdminService : IAdminService
|
||||||
@ -24,11 +26,12 @@ public class AdminService : IAdminService
|
|||||||
|
|
||||||
public async Task AddMuseum(MuseumDto museumDto)
|
public async Task AddMuseum(MuseumDto museumDto)
|
||||||
{
|
{
|
||||||
Museum m = new();
|
|
||||||
m.Name = museumDto.Name;
|
|
||||||
City c = await _databaseContext.Cities.FirstOrDefaultAsync(x => x.Name.ToLower() == museumDto.City.ToLower());
|
City c = await _databaseContext.Cities.FirstOrDefaultAsync(x => x.Name.ToLower() == museumDto.City.ToLower());
|
||||||
if (c==null)
|
if (c==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Museum m = new();
|
||||||
|
m.Name = museumDto.Name;
|
||||||
m.City = c;
|
m.City = c;
|
||||||
m.Price = museumDto.Price;
|
m.Price = museumDto.Price;
|
||||||
m.Latitude = museumDto.Latitude;
|
m.Latitude = museumDto.Latitude;
|
||||||
@ -58,4 +61,37 @@ public class AdminService : IAdminService
|
|||||||
await _databaseContext.SaveChangesAsync();
|
await _databaseContext.SaveChangesAsync();
|
||||||
return "OK";
|
return "OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<string> AddHotel(HotelDto hotelDto)
|
||||||
|
{
|
||||||
|
var c = await _databaseContext.Cities.FirstOrDefaultAsync(x => x.Name.ToLower() == hotelDto.City.ToLower());
|
||||||
|
if (c==null)
|
||||||
|
return $"City {c} not exist";
|
||||||
|
|
||||||
|
Hotel h = new();
|
||||||
|
h.Name = hotelDto.Name;
|
||||||
|
h.City = hotelDto.City;
|
||||||
|
h.Price = hotelDto.Price;
|
||||||
|
h.Address = hotelDto.Address;
|
||||||
|
h.ImageURL = hotelDto.ImageURL;
|
||||||
|
await _databaseContext.Hotels.AddAsync(h);
|
||||||
|
await _databaseContext.SaveChangesAsync();
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> AddAttraction(AttractionDto attractionDto)
|
||||||
|
{
|
||||||
|
var c = await _databaseContext.Cities.FirstOrDefaultAsync(x => x.Name.ToLower() == attractionDto.City.ToLower());
|
||||||
|
if (c==null)
|
||||||
|
return $"City {c} not exist";
|
||||||
|
|
||||||
|
Attraction h = new();
|
||||||
|
h.Name = attractionDto.Name;
|
||||||
|
h.City = attractionDto.City;
|
||||||
|
h.Address = attractionDto.Address;
|
||||||
|
h.ImageURL = attractionDto.ImageURL;
|
||||||
|
await _databaseContext.Attractions.AddAsync(h);
|
||||||
|
await _databaseContext.SaveChangesAsync();
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,13 +8,14 @@ namespace FichaBackend.Services;
|
|||||||
public interface IPublicDataService
|
public interface IPublicDataService
|
||||||
{
|
{
|
||||||
public Task<IEnumerable<City>> GetAllCity();
|
public Task<IEnumerable<City>> GetAllCity();
|
||||||
public Task<IEnumerable<FilmDto>> GetAllFilmsInCity(string cityName);
|
|
||||||
public Task<IEnumerable<CardQuestion>> GetAllCards();
|
public Task<IEnumerable<CardQuestion>> GetAllCards();
|
||||||
public Task<IEnumerable<Museum>> GetAllMuseumsInCity(string cityName);
|
|
||||||
public Task UpdateFilmsInCity(IEnumerable<FilmDto> films);
|
public Task UpdateFilmsInCity(IEnumerable<FilmDto> films);
|
||||||
public bool CityExsist(string cityName);
|
public bool CityExsist(string cityName);
|
||||||
public Task<IEnumerable<MuseumDto>> GetAllMuseum(string cityName = "");
|
public Task<IEnumerable<MuseumDto>> GetAllMuseum(string cityName = "");
|
||||||
public Task<IEnumerable<GuideDto>> GetAllGuides(string cityName = "");
|
public Task<IEnumerable<GuideDto>> GetAllGuides(string cityName = "");
|
||||||
|
public Task<IEnumerable<HotelDto>> GetAllHotels(string cityName = "");
|
||||||
|
public Task<IEnumerable<FilmDto>> GetAllFilms(string cityName);
|
||||||
|
public Task<IEnumerable<AttractionDto>> GetAllAttractions(string cityName = "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublicDataService : IPublicDataService
|
public class PublicDataService : IPublicDataService
|
||||||
@ -33,11 +34,24 @@ public class PublicDataService : IPublicDataService
|
|||||||
return await _databaseContext.Cities.ToListAsync();
|
return await _databaseContext.Cities.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<FilmDto>> GetAllFilmsInCity(string cityName)
|
public async Task<IEnumerable<FilmDto>> GetAllFilms(string cityName)
|
||||||
{
|
{
|
||||||
var films = await _databaseContext.Films.Where(x => x.City.Name.ToLower() == cityName.ToLower()).ToListAsync();
|
IEnumerable<Film> films = cityName == "" ? await _databaseContext.Films.ToListAsync() :
|
||||||
var destinations = _mapper.Map<List<Film>, List<FilmDto>>(films);
|
_databaseContext.Films.Where(x => x.City.Name.ToLower() == cityName.ToLower());
|
||||||
return destinations;
|
return _mapper.Map<IEnumerable<Film>, IEnumerable<FilmDto>>(films);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<AttractionDto>> GetAllAttractions(string cityName = "")
|
||||||
|
{
|
||||||
|
IEnumerable<Attraction> attractions = cityName == "" ? await _databaseContext.Attractions.ToListAsync() :
|
||||||
|
_databaseContext.Attractions.Where(x => x.City.ToLower() == cityName.ToLower());
|
||||||
|
return _mapper.Map<IEnumerable<Attraction>, IEnumerable<AttractionDto>>(attractions);
|
||||||
|
}
|
||||||
|
public async Task<IEnumerable<HotelDto>> GetAllHotels(string cityName = "")
|
||||||
|
{
|
||||||
|
IEnumerable<Hotel> hotels = cityName == "" ? await _databaseContext.Hotels.ToListAsync() :
|
||||||
|
_databaseContext.Hotels.Where(x => x.City.ToLower() == cityName.ToLower());
|
||||||
|
return _mapper.Map<IEnumerable<Hotel>, IEnumerable<HotelDto>>(hotels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<CardQuestion>> GetAllCards()
|
public async Task<IEnumerable<CardQuestion>> GetAllCards()
|
||||||
@ -45,11 +59,6 @@ public class PublicDataService : IPublicDataService
|
|||||||
return await _databaseContext.CardQuestions.ToListAsync();
|
return await _databaseContext.CardQuestions.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Museum>> GetAllMuseumsInCity(string cityName)
|
|
||||||
{
|
|
||||||
return await _databaseContext.Museums.Where(x => x.City.Name.ToLower() == cityName.ToLower()).ToListAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateFilmsInCity(IEnumerable<FilmDto> films)
|
public async Task UpdateFilmsInCity(IEnumerable<FilmDto> films)
|
||||||
{
|
{
|
||||||
await _databaseContext.Films.Where(x => x.City.Name == films.First().City).ForEachAsync(x => _databaseContext.Films.Remove(x));
|
await _databaseContext.Films.Where(x => x.City.Name == films.First().City).ForEachAsync(x => _databaseContext.Films.Remove(x));
|
||||||
@ -89,4 +98,5 @@ public class PublicDataService : IPublicDataService
|
|||||||
_databaseContext.Guides.Where(x => x.City.Any(y => y.Name.ToLower() == cityName.ToLower()));
|
_databaseContext.Guides.Where(x => x.City.Any(y => y.Name.ToLower() == cityName.ToLower()));
|
||||||
return _mapper.Map<IEnumerable<Guide>, IEnumerable<GuideDto>>(guides);
|
return _mapper.Map<IEnumerable<Guide>, IEnumerable<GuideDto>>(guides);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -14,5 +14,9 @@ public class MappingProfiles : Profile
|
|||||||
CreateMap<MuseumDto, Museum>();
|
CreateMap<MuseumDto, Museum>();
|
||||||
CreateMap<Guide, GuideDto>();
|
CreateMap<Guide, GuideDto>();
|
||||||
CreateMap<GuideDto, Guide>();
|
CreateMap<GuideDto, Guide>();
|
||||||
|
CreateMap<Hotel, HotelDto>();
|
||||||
|
CreateMap<HotelDto, Hotel>();
|
||||||
|
CreateMap<Attraction, AttractionDto>();
|
||||||
|
CreateMap<AttractionDto, Attraction>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"ConnectionStrings": {
|
|
||||||
"DefaultConnection": "Host=192.168.0.46;Port=5432;Database=backend;Username=prod;Password="
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user