привязка и прочая фигня
This commit is contained in:
parent
b0cf340079
commit
933b919e68
@ -15,5 +15,7 @@ namespace TravelAgencyContracts.BindingModels
|
||||
public int GuideId { get; set; }
|
||||
|
||||
public Dictionary<int, ITourModel> ExcursionGroupTours { get; set; } = new();
|
||||
|
||||
public Dictionary<int, IPlaceModel> ExcursionGroupPlaces { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,7 @@ namespace TravelAgencyContracts.ViewModels
|
||||
public string? GuideFIO { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, ITourModel> ExcursionGroupTours { get; set; } = new();
|
||||
|
||||
public Dictionary<int, IPlaceModel> ExcursionGroupPlaces { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,7 @@
|
||||
int GuideId { get; }
|
||||
|
||||
Dictionary<int, ITourModel> ExcursionGroupTours { get; }
|
||||
|
||||
Dictionary<int, IPlaceModel> ExcursionGroupPlaces { get; }
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
.Include(x => x.Guide)
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Include(x => x.Places)
|
||||
.ThenInclude(x => x.Place)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -32,6 +34,8 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
.Include(x => x.Guide)
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Include(x => x.Places)
|
||||
.ThenInclude(x => x.Place)
|
||||
.Where(x => x.ExcursionGroupName.Contains(model.ExcursionGroupName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -44,6 +48,8 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
.Include(x => x.Guide)
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Include(x => x.Places)
|
||||
.ThenInclude(x => x.Place)
|
||||
.Where(x => x.UserId.Equals(model.UserId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -56,6 +62,8 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
.Include(x => x.Guide)
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Include(x => x.Places)
|
||||
.ThenInclude(x => x.Place)
|
||||
.Where(x => x.GuideId.Equals(model.GuideId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -76,6 +84,8 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
.Include(x => x.Guide)
|
||||
.Include(x => x.Tours)
|
||||
.ThenInclude(x => x.Tour)
|
||||
.Include(x => x.Places)
|
||||
.ThenInclude(x => x.Place)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ExcursionGroupName) && x.ExcursionGroupName == model.ExcursionGroupName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
@ -108,6 +118,7 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
excursionGroup.Update(model);
|
||||
context.SaveChanges();
|
||||
excursionGroup.UpdateTours(context, model);
|
||||
excursionGroup.UpdatePlaces(context, model);
|
||||
transaction.Commit();
|
||||
return excursionGroup.GetViewModel;
|
||||
}
|
||||
@ -123,6 +134,7 @@ namespace TravelAgencyDatabaseImplement.Implements
|
||||
using var context = new TravelAgencyDatabase();
|
||||
var element = context.ExcursionGroups
|
||||
.Include(x => x.Tours)
|
||||
.Include(x => x.Places)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ using TravelAgencyDatabaseImplement;
|
||||
namespace TravelAgencyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(TravelAgencyDatabase))]
|
||||
[Migration("20240529001818_InitialCreate")]
|
||||
[Migration("20240529060724_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -89,6 +89,29 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
b.ToTable("ExcursionGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupPlace", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ExcursionGroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PlaceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExcursionGroupId");
|
||||
|
||||
b.HasIndex("PlaceId");
|
||||
|
||||
b.ToTable("ExcursionGroupPlaces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -328,6 +351,25 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupPlace", b =>
|
||||
{
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
|
||||
.WithMany("Places")
|
||||
.HasForeignKey("ExcursionGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place")
|
||||
.WithMany("ExcursionGroups")
|
||||
.HasForeignKey("PlaceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ExcursionGroup");
|
||||
|
||||
b.Navigation("Place");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
|
||||
{
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
|
||||
@ -414,6 +456,8 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
|
||||
{
|
||||
b.Navigation("Places");
|
||||
|
||||
b.Navigation("Tours");
|
||||
});
|
||||
|
||||
@ -426,6 +470,8 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
|
||||
{
|
||||
b.Navigation("ExcursionGroups");
|
||||
|
||||
b.Navigation("Excursions");
|
||||
|
||||
b.Navigation("Trips");
|
@ -183,6 +183,32 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ExcursionGroupPlaces",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ExcursionGroupId = table.Column<int>(type: "int", nullable: false),
|
||||
PlaceId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ExcursionGroupPlaces", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ExcursionGroupPlaces_ExcursionGroups_ExcursionGroupId",
|
||||
column: x => x.ExcursionGroupId,
|
||||
principalTable: "ExcursionGroups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ExcursionGroupPlaces_Places_PlaceId",
|
||||
column: x => x.PlaceId,
|
||||
principalTable: "Places",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ExcursionGroupTours",
|
||||
columns: table => new
|
||||
@ -235,6 +261,16 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ExcursionGroupPlaces_ExcursionGroupId",
|
||||
table: "ExcursionGroupPlaces",
|
||||
column: "ExcursionGroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ExcursionGroupPlaces_PlaceId",
|
||||
table: "ExcursionGroupPlaces",
|
||||
column: "PlaceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ExcursionGroups_GuideId",
|
||||
table: "ExcursionGroups",
|
||||
@ -299,6 +335,9 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ExcursionGroupPlaces");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ExcursionGroupTours");
|
||||
|
@ -86,6 +86,29 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
b.ToTable("ExcursionGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupPlace", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ExcursionGroupId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PlaceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExcursionGroupId");
|
||||
|
||||
b.HasIndex("PlaceId");
|
||||
|
||||
b.ToTable("ExcursionGroupPlaces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -325,6 +348,25 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupPlace", b =>
|
||||
{
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
|
||||
.WithMany("Places")
|
||||
.HasForeignKey("ExcursionGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place")
|
||||
.WithMany("ExcursionGroups")
|
||||
.HasForeignKey("PlaceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ExcursionGroup");
|
||||
|
||||
b.Navigation("Place");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
|
||||
{
|
||||
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
|
||||
@ -411,6 +453,8 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
|
||||
{
|
||||
b.Navigation("Places");
|
||||
|
||||
b.Navigation("Tours");
|
||||
});
|
||||
|
||||
@ -423,6 +467,8 @@ namespace TravelAgencyDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
|
||||
{
|
||||
b.Navigation("ExcursionGroups");
|
||||
|
||||
b.Navigation("Excursions");
|
||||
|
||||
b.Navigation("Trips");
|
||||
|
@ -47,6 +47,25 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
[ForeignKey("ExcursionGroupId")]
|
||||
public virtual List<ExcursionGroupTour> Tours { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IPlaceModel>? _excursionGroupPlaces = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IPlaceModel> ExcursionGroupPlaces
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_excursionGroupPlaces == null)
|
||||
{
|
||||
_excursionGroupPlaces = Places
|
||||
.ToDictionary(recPC => recPC.PlaceId, recPC => recPC.Place as IPlaceModel);
|
||||
}
|
||||
return _excursionGroupPlaces;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("ExcursionGroupId")]
|
||||
public virtual List<ExcursionGroupPlace> Places { get; set; } = new();
|
||||
|
||||
public static ExcursionGroup? Create(TravelAgencyDatabase context, ExcursionGroupBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -65,6 +84,10 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
Tours = model.ExcursionGroupTours.Select(x => new ExcursionGroupTour
|
||||
{
|
||||
Tour = context.Tours.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Places = model.ExcursionGroupPlaces.Select(x => new ExcursionGroupPlace
|
||||
{
|
||||
Place = context.Places.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@ -90,7 +113,8 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
UserId = UserId,
|
||||
GuideId = GuideId,
|
||||
GuideFIO = Guide?.GuideFIO,
|
||||
ExcursionGroupTours = ExcursionGroupTours
|
||||
ExcursionGroupTours = ExcursionGroupTours,
|
||||
ExcursionGroupPlaces = ExcursionGroupPlaces
|
||||
};
|
||||
|
||||
public void UpdateTours(TravelAgencyDatabase context, ExcursionGroupBindingModel model)
|
||||
@ -118,5 +142,31 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
}
|
||||
_excursionGroupTours = null;
|
||||
}
|
||||
|
||||
public void UpdatePlaces(TravelAgencyDatabase context, ExcursionGroupBindingModel model)
|
||||
{
|
||||
var excursionGroupPlaces = context.ExcursionGroupPlaces.Where(rec => rec.ExcursionGroupId == model.Id).ToList();
|
||||
if (excursionGroupPlaces != null && excursionGroupPlaces.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ExcursionGroupPlaces.RemoveRange(excursionGroupPlaces.Where(rec => !model.ExcursionGroupPlaces.ContainsKey(rec.PlaceId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
var excursionGroup = context.ExcursionGroups.First(x => x.Id == Id);
|
||||
foreach (var et in model.ExcursionGroupPlaces)
|
||||
{
|
||||
|
||||
if (excursionGroupPlaces!.Any(x => x.PlaceId == et.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
context.ExcursionGroupPlaces.Add(new ExcursionGroupPlace
|
||||
{
|
||||
ExcursionGroup = excursionGroup,
|
||||
Place = context.Places.First(x => x.Id == et.Key)
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_excursionGroupPlaces = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace TravelAgencyDatabaseImplement.Models
|
||||
{
|
||||
public class ExcursionGroupPlace
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ExcursionGroupId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int PlaceId { get; set; }
|
||||
|
||||
public virtual ExcursionGroup ExcursionGroup { get; set; } = new();
|
||||
|
||||
public virtual Place Place { get; set; } = new();
|
||||
}
|
||||
}
|
@ -28,6 +28,9 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
[ForeignKey("PlaceId")]
|
||||
public virtual List<Excursion> Excursions { get; set; } = new();
|
||||
|
||||
[ForeignKey("PlaceId")]
|
||||
public virtual List<ExcursionGroupPlace> ExcursionGroups { get; set; } = new();
|
||||
|
||||
public static Place? Create(PlaceBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -24,6 +24,8 @@ namespace TravelAgencyDatabaseImplement
|
||||
|
||||
public virtual DbSet<ExcursionGroupTour> ExcursionGroupTours { set; get; }
|
||||
|
||||
public virtual DbSet<ExcursionGroupPlace> ExcursionGroupPlaces { set; get; }
|
||||
|
||||
public virtual DbSet<Guide> Guides { set; get; }
|
||||
|
||||
public virtual DbSet<Place> Places { set; get; }
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TravelAgencyContracts.BindingModels;
|
||||
using TravelAgencyContracts.BusinessLogicsContracts;
|
||||
using TravelAgencyContracts.SearchModels;
|
||||
@ -18,12 +20,15 @@ namespace TravelAgencyWebApp.Controllers
|
||||
|
||||
private readonly IGuideLogic _guideLogic;
|
||||
|
||||
public ExcursionGroupController(ILogger<ExcursionGroupController> logger, IExcursionGroupLogic excursionGroupLogic, ITourLogic tourLogic, IGuideLogic guideLogic)
|
||||
private readonly IPlaceLogic _placeLogic;
|
||||
|
||||
public ExcursionGroupController(ILogger<ExcursionGroupController> logger, IExcursionGroupLogic excursionGroupLogic, ITourLogic tourLogic, IGuideLogic guideLogic, IPlaceLogic placeLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_excursionGroupLogic = excursionGroupLogic;
|
||||
_tourLogic = tourLogic;
|
||||
_guideLogic = guideLogic;
|
||||
_placeLogic = placeLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -129,6 +134,8 @@ namespace TravelAgencyWebApp.Controllers
|
||||
excursionGroupTours.Add(tourId, _tourLogic.ReadElement(new TourSearchModel { Id = tourId })!);
|
||||
}
|
||||
|
||||
var excursionGroup = _excursionGroupLogic.ReadElement(new ExcursionGroupSearchModel() { Id = id });
|
||||
|
||||
_excursionGroupLogic.Update(new ExcursionGroupBindingModel
|
||||
{
|
||||
Id = id,
|
||||
@ -136,7 +143,8 @@ namespace TravelAgencyWebApp.Controllers
|
||||
ParticipantsAmount = participantsAmount,
|
||||
UserId = LoggedinUser.User.Id,
|
||||
GuideId = guide,
|
||||
ExcursionGroupTours = excursionGroupTours
|
||||
ExcursionGroupTours = excursionGroupTours,
|
||||
ExcursionGroupPlaces = excursionGroup.ExcursionGroupPlaces
|
||||
});
|
||||
|
||||
Response.Redirect("/ExcursionGroup/ExcursionGroups");
|
||||
@ -157,5 +165,61 @@ namespace TravelAgencyWebApp.Controllers
|
||||
|
||||
Response.Redirect("/ExcursionGroup/ExcursionGroups");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ConnectGroupToPlace()
|
||||
{
|
||||
if (LoggedinUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.ExcursionGroups = _excursionGroupLogic.ReadList(new ExcursionGroupSearchModel
|
||||
{
|
||||
UserId = LoggedinUser.User.Id,
|
||||
});
|
||||
|
||||
ViewBag.Places = _placeLogic.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult ConnectGroupToPlace(int excursionGroupId, int placeId)
|
||||
{
|
||||
if (LoggedinUser.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (excursionGroupId <= 0 || placeId <= 0)
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
var excursionGroup = _excursionGroupLogic.ReadElement(new ExcursionGroupSearchModel() { Id = excursionGroupId });
|
||||
Dictionary<int, IPlaceModel> excursionGroupPlaces = excursionGroup.ExcursionGroupPlaces;
|
||||
if (!excursionGroupPlaces.ContainsKey(placeId))
|
||||
excursionGroupPlaces.Add(placeId, _placeLogic.ReadElement(new PlaceSearchModel { Id = placeId })!);
|
||||
|
||||
_excursionGroupLogic.Update(new ExcursionGroupBindingModel
|
||||
{
|
||||
Id = excursionGroupId,
|
||||
ExcursionGroupName = excursionGroup.ExcursionGroupName,
|
||||
ParticipantsAmount = excursionGroup.ParticipantsAmount,
|
||||
UserId = LoggedinUser.User.Id,
|
||||
GuideId = excursionGroup.GuideId,
|
||||
ExcursionGroupTours = excursionGroup.ExcursionGroupTours,
|
||||
ExcursionGroupPlaces = excursionGroupPlaces
|
||||
});
|
||||
|
||||
ViewBag.ExcursionGroups = _excursionGroupLogic.ReadList(new ExcursionGroupSearchModel
|
||||
{
|
||||
UserId = LoggedinUser.User.Id,
|
||||
});
|
||||
|
||||
ViewBag.Places = _placeLogic.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,42 @@ namespace TravelAgencyWebApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
if (LoggedinUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(LoggedinUser.User);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Privacy(string userFIO, string email, string phoneNumber, string password)
|
||||
{
|
||||
if (LoggedinUser.User == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(userFIO) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
_userLogic.Update(new UserBindingModel
|
||||
{
|
||||
Id = LoggedinUser.User.Id,
|
||||
UserFIO = userFIO,
|
||||
Email = email,
|
||||
PhoneNumber = phoneNumber,
|
||||
Password = password
|
||||
});
|
||||
|
||||
LoggedinUser.User.UserFIO = userFIO;
|
||||
LoggedinUser.User.Email = email;
|
||||
LoggedinUser.User.PhoneNumber = phoneNumber;
|
||||
LoggedinUser.User.Password = password;
|
||||
|
||||
Response.Redirect("Privacy");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
@ -139,6 +174,10 @@ namespace TravelAgencyWebApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult ReportMenu()
|
||||
{
|
||||
if (LoggedinUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
|
@ -19,14 +19,14 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Место для посещения:</div>
|
||||
<div class="col-8">
|
||||
<div class="col-2">
|
||||
<select id="place" name="place" class="form-control" asp-items="@(new SelectList(@ViewBag.Places,"Id", "PlaceName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Туры</div>
|
||||
<div class="fw-bold fs-4">Туры</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="tourstable" class="display">
|
||||
<table id="tourstable" class="display col-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
|
@ -22,7 +22,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Место для посещения:</div>
|
||||
<div class="col-8">
|
||||
<div class="col-2">
|
||||
<select id="place" name="place" class="form-control">
|
||||
@foreach (var place in ViewBag.Places)
|
||||
{
|
||||
@ -33,9 +33,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Туры</div>
|
||||
<div class="fw-bold fs-4">Туры</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="tourstable" class="display">
|
||||
<table id="tourstable" class="display col-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
|
@ -0,0 +1,58 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create group to place";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-5">Связывание группы и места для посещения</h2>
|
||||
</div>
|
||||
<form method="post" class="my-5">
|
||||
<div class="row my-3 d-flex justify-content-center">
|
||||
<div class="col-2">Группа:</div>
|
||||
<div class="col-2">
|
||||
<select id="excursionGroupId" name="excursionGroupId" class="form-control" asp-items="@(new SelectList(@ViewBag.ExcursionGroups,"Id", "ExcursionGroupName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-3 d-flex justify-content-center">
|
||||
<div class="col-2">Место:</div>
|
||||
<div class="col-2">
|
||||
<select id="placeId" name="placeId" class="form-control" asp-items="@(new SelectList(@ViewBag.Places,"Id", "PlaceName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="my-3 d-flex justify-content-center"><input type="submit" value="Связать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Группа
|
||||
</th>
|
||||
<th>
|
||||
Место
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var eg in ViewBag.ExcursionGroups)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@eg.ExcursionGroupName
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
foreach (var ep in eg.ExcursionGroupPlaces) {
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
@ep.Value.PlaceName
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
@ -15,14 +15,14 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Гид:</div>
|
||||
<div class="col-8">
|
||||
<div class="col-2">
|
||||
<select id="guide" name="guide" class="form-control" asp-items="@(new SelectList(@ViewBag.Guides,"Id", "GuideFIO"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Туры</div>
|
||||
<div class="fw-bold fs-4">Туры</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="tourstable" class="display">
|
||||
<table id="tourstable" class="display col-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
|
@ -32,10 +32,7 @@
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Описание
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
Кол-во участников
|
||||
</th>
|
||||
<th>
|
||||
Гид
|
||||
|
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Гид:</div>
|
||||
<div class="col-8">
|
||||
<div class="col-2">
|
||||
<select id="guide" name="guide" class="form-control">
|
||||
@foreach (var guide in ViewBag.Guides)
|
||||
{
|
||||
@ -29,9 +29,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Туры</div>
|
||||
<div class="fw-bold fs-4">Туры</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="tourstable" class="display">
|
||||
<table id="tourstable" class="display col-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин(почта):</div>
|
||||
<div class="col-8"><input type="text" name="login" value="@Model.Email" /></div>
|
||||
<div class="col-8"><input type="text" name="email" value="@Model.Email" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
@ -19,11 +19,11 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8"><input type="text" name="phone" value="@Model.PhoneNumber" /></div>
|
||||
<div class="col-8"><input type="text" name="phoneNumber" value="@Model.PhoneNumber" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fio" value="@Model.UserFIO" /></div>
|
||||
<div class="col-8"><input type="text" name="userFIO" value="@Model.UserFIO" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -51,12 +51,14 @@
|
||||
{
|
||||
foreach (var record in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@record.Tour.TourName</td>
|
||||
<td>@record.Tour.Price</td>
|
||||
<td>@record.Tour.TourDate</td>
|
||||
<td>@record.Tour.TourDate.ToShortDateString()</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
var excursionGroups = new List<ExcursionGroupViewModel>(record.ExcursionGroups);
|
||||
var guides = new List<GuideViewModel>(record.Guides);
|
||||
for (int i = 0; i < excursionGroups.Count; i++)
|
||||
|
@ -9,9 +9,9 @@
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div>Выберите тур:</div>
|
||||
<p fw-bold fs-4>Выберите тур:</p>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="tourstable" class="display">
|
||||
<table id="tourstable" class="display col-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Турфирма «Иван Сусанин»</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Турфирма «Иван Сусанин»</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -42,6 +42,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="ExcursionGroup" asp-action="ExcursionGroups">Экскурсионные группы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="ExcursionGroup" asp-action="ConnectGroupToPlace">Связать группу с местом</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportMenu">Отчеты</a>
|
||||
</li>
|
||||
@ -57,7 +60,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Иван Сусанин - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
© 2024 - Иван Сусанин - <a asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
@ -49,19 +49,19 @@
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => tour.Id)
|
||||
@tour.Id
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => tour.TourName)
|
||||
@tour.TourName
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => tour.TourDescription)
|
||||
@tour.TourDescription
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => tour.Price)
|
||||
@tour.Price
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => tour.TourDate)
|
||||
@tour.TourDate.ToShortDateString()
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateTour", "/Tour", new { id = tour.Id })'">Изменить</button>
|
||||
|
Loading…
Reference in New Issue
Block a user