final commit
This commit is contained in:
parent
09fc8ca9de
commit
d4966200cd
@ -14,6 +14,8 @@ namespace HotelBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
public class OrganiserLogic : IOrganiserLogic
|
public class OrganiserLogic : IOrganiserLogic
|
||||||
{
|
{
|
||||||
|
private readonly int _loginMaxLength = 25;
|
||||||
|
private readonly int _passwordMaxLength = 50;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrganiserStorage _organiserStorage;
|
private readonly IOrganiserStorage _organiserStorage;
|
||||||
|
|
||||||
@ -104,36 +106,52 @@ namespace HotelBusinessLogic.BusinessLogic
|
|||||||
public void CheckModel(OrganiserBindingModel model, bool withParams = true)
|
public void CheckModel(OrganiserBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
if (!withParams)
|
if (!withParams)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(model.OrganiserLogin))
|
|
||||||
throw new ArgumentException("Нет логина организатора", nameof(model.OrganiserLogin));
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.OrganiserPassword))
|
|
||||||
throw new ArgumentException("Нет пароля организатора", nameof(model.OrganiserLogin));
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.OrganiserEmail))
|
|
||||||
throw new ArgumentException("Нет эл. почты организатора", nameof(model.OrganiserEmail));
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.OrganiserNumber))
|
|
||||||
throw new ArgumentException("Нет номера организатора", nameof(model.OrganiserNumber));
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.OrganiserFIO))
|
if (string.IsNullOrEmpty(model.OrganiserFIO))
|
||||||
throw new ArgumentException("Нет ФИО организатора", nameof(model.OrganiserFIO));
|
|
||||||
|
|
||||||
_logger.LogInformation("Organiser. OrganiserFIO: {OrganiserFIO}. OrganiserLogin: {OrganiserLogin}. Id: {Id}", model.OrganiserFIO, model.OrganiserLogin, model.Id);
|
|
||||||
|
|
||||||
var element = _organiserStorage.GetElement(new OrganiserSearchModel
|
|
||||||
{
|
{
|
||||||
OrganiserEmail = model.OrganiserEmail,
|
throw new ArgumentNullException("Нет ФИО организатора", nameof(model.OrganiserFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.OrganiserLogin))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина организатора", nameof(model.OrganiserLogin));
|
||||||
|
}
|
||||||
|
if (model.OrganiserLogin.Length > _loginMaxLength)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Логин превышает допустимое количество символов", nameof(model.OrganiserLogin));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.OrganiserNumber))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет номера телефона организатора", nameof(model.OrganiserNumber));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.OrganiserEmail))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет эл. почты администратора", nameof(model.OrganiserEmail));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.OrganiserPassword))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля организатора", nameof(model.OrganiserPassword));
|
||||||
|
}
|
||||||
|
if (model.OrganiserPassword.Length > _passwordMaxLength)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Пароль превышает допустимое количество символов", nameof(model.OrganiserPassword));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Organiser. OrganiserFIO: {OrganiserFIO}. OrganiserLogin: {OrganiserLogin}. OrganiserNumber: {OrganiserNumber}.OrganiserEmail: {OrganiserEmail}.OrganiserPassword: {OrganiserPassword}.Id: {Id}",
|
||||||
|
model.OrganiserFIO, model.OrganiserLogin, model.OrganiserNumber, model.OrganiserEmail, model.OrganiserPassword, model.Id);
|
||||||
|
|
||||||
|
var elementEmail = _organiserStorage.GetElement(new OrganiserSearchModel
|
||||||
|
{
|
||||||
|
OrganiserEmail = model.OrganiserEmail
|
||||||
});
|
});
|
||||||
|
if (elementEmail != null && elementEmail.Id != model.Id)
|
||||||
if (element != null && element.Id == model.Id)
|
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Организатор с таким логином уже есть");
|
throw new InvalidOperationException("Администратор с такой почтой уже есть");
|
||||||
}
|
}
|
||||||
|
|
||||||
var elementLogin = _organiserStorage.GetElement(new OrganiserSearchModel
|
var elementLogin = _organiserStorage.GetElement(new OrganiserSearchModel
|
||||||
|
@ -11,7 +11,7 @@ namespace HotelContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int RoomNumber { get; set; }
|
public int RoomNumber { get; set; }
|
||||||
public DateTime? DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
public double RoomPrice { get; set; }
|
public double RoomPrice { get; set; }
|
||||||
public int AdministratorId { get; set; }
|
public int AdministratorId { get; set; }
|
||||||
public int? MealPlanId { get; set; }
|
public int? MealPlanId { get; set; }
|
||||||
|
@ -14,7 +14,7 @@ namespace HotelContracts.ViewModels
|
|||||||
[DisplayName("Номер комнаты")]
|
[DisplayName("Номер комнаты")]
|
||||||
public int RoomNumber { get; set; }
|
public int RoomNumber { get; set; }
|
||||||
[DisplayName("Дата создания номера")]
|
[DisplayName("Дата создания номера")]
|
||||||
public DateTime? DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
[DisplayName("Стоимость номера")]
|
[DisplayName("Стоимость номера")]
|
||||||
public double RoomPrice { get; set; }
|
public double RoomPrice { get; set; }
|
||||||
public int AdministratorId { get; set; }
|
public int AdministratorId { get; set; }
|
||||||
|
@ -26,25 +26,12 @@ namespace HotelDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<ConferenceBookingViewModel> GetFilteredList(ConferenceBookingSearchModel model)
|
public List<ConferenceBookingViewModel> GetFilteredList(ConferenceBookingSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.AdministratorId.HasValue)
|
if (!model.AdministratorId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new HotelDataBase();
|
using var context = new HotelDataBase();
|
||||||
if (model.DateFrom.HasValue)
|
if (model.AdministratorId.HasValue)
|
||||||
{
|
|
||||||
return context.ConferenceBookings
|
|
||||||
.Include(x => x.Dinners)
|
|
||||||
.ThenInclude(x => x.Dinner)
|
|
||||||
.ThenInclude(x => x.RoomDinners)
|
|
||||||
.ThenInclude(x => x.Room)
|
|
||||||
.Include(x => x.Conference)
|
|
||||||
.Include(x => x.Administrator)
|
|
||||||
.Where(x => x.DateСonference >= model.DateFrom && x.DateСonference <= model.DateTo && x.AdministratorId == model.AdministratorId)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
else if (model.AdministratorId.HasValue)
|
|
||||||
{
|
{
|
||||||
return context.ConferenceBookings
|
return context.ConferenceBookings
|
||||||
.Include(x => x.Dinners)
|
.Include(x => x.Dinners)
|
||||||
|
@ -32,13 +32,26 @@ namespace HotelDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<ConferenceViewModel> GetFilteredList(ConferenceSearchModel model)
|
public List<ConferenceViewModel> GetFilteredList(ConferenceSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.OrganiserId.HasValue)
|
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.OrganiserId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new HotelDataBase();
|
using var context = new HotelDataBase();
|
||||||
|
|
||||||
if (model.OrganiserId.HasValue)
|
if (model.DateFrom.HasValue)
|
||||||
|
{
|
||||||
|
return context.Conferences
|
||||||
|
.Include(x => x.Participants)
|
||||||
|
.ThenInclude(x => x.Participant)
|
||||||
|
.ThenInclude(x => x.MealPlanParticipants)
|
||||||
|
.ThenInclude(x => x.MealPlan)
|
||||||
|
.Include(x => x.Bookings)
|
||||||
|
.Include(x => x.Organiser)
|
||||||
|
.Where(x => x.StartDate >= model.DateFrom && x.StartDate <= model.DateTo && x.OrganiserId == model.OrganiserId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.OrganiserId.HasValue)
|
||||||
return context.Conferences
|
return context.Conferences
|
||||||
.Include(x => x.Participants)
|
.Include(x => x.Participants)
|
||||||
.ThenInclude(x => x.Participant)
|
.ThenInclude(x => x.Participant)
|
||||||
|
@ -35,14 +35,30 @@ namespace HotelDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<RoomViewModel> GetFilteredList(RoomSearchModel model)
|
public List<RoomViewModel> GetFilteredList(RoomSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.AdministratorId.HasValue)
|
if (!model.DateFrom.HasValue && !model.DateTo.HasValue && !model.Id.HasValue && !model.AdministratorId.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
using var context = new HotelDataBase();
|
using var context = new HotelDataBase();
|
||||||
|
|
||||||
if (model.AdministratorId.HasValue)
|
if (model.DateFrom.HasValue)
|
||||||
|
{
|
||||||
|
return context.Rooms
|
||||||
|
.Include(x => x.Dinners)
|
||||||
|
.ThenInclude(x => x.Dinner)
|
||||||
|
.ThenInclude(x => x.ConferenceBookingDinner)
|
||||||
|
.ThenInclude(x => x.ConferenceBooking)
|
||||||
|
.Include(x => x.MealPlanRooms)
|
||||||
|
.ThenInclude(x => x.MealPlan)
|
||||||
|
.ThenInclude(x => x.Participants)
|
||||||
|
.ThenInclude(x => x.Participant)
|
||||||
|
.Include(x => x.Administrator)
|
||||||
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo && x.AdministratorId == model.AdministratorId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.AdministratorId.HasValue)
|
||||||
{
|
{
|
||||||
return context.Rooms
|
return context.Rooms
|
||||||
.Include(x => x.Dinners)
|
.Include(x => x.Dinners)
|
||||||
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace HotelDataBaseImplement.Migrations
|
namespace HotelDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(HotelDataBase))]
|
[DbContext(typeof(HotelDataBase))]
|
||||||
[Migration("20240501104100_NewMigration")]
|
[Migration("20240501154837_SeqMigration")]
|
||||||
partial class NewMigration
|
partial class SeqMigration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -73,6 +73,9 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
b.Property<int>("OrganiserId")
|
b.Property<int>("OrganiserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<string>("Subject")
|
b.Property<string>("Subject")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -329,8 +332,8 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
b.Property<int>("AdministratorId")
|
b.Property<int>("AdministratorId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("CountBeds")
|
b.Property<DateTime>("DateCreate")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int?>("MealPlanId")
|
b.Property<int?>("MealPlanId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace HotelDataBaseImplement.Migrations
|
namespace HotelDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class NewMigration : Migration
|
public partial class SeqMigration : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
@ -76,6 +76,7 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
ConferenceName = table.Column<string>(type: "text", nullable: false),
|
ConferenceName = table.Column<string>(type: "text", nullable: false),
|
||||||
Subject = table.Column<string>(type: "text", nullable: false),
|
Subject = table.Column<string>(type: "text", nullable: false),
|
||||||
|
StartDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||||
OrganiserId = table.Column<int>(type: "integer", nullable: false)
|
OrganiserId = table.Column<int>(type: "integer", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
@ -165,8 +166,8 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
RoomNumber = table.Column<int>(type: "integer", nullable: false),
|
RoomNumber = table.Column<int>(type: "integer", nullable: false),
|
||||||
CountBeds = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
RoomPrice = table.Column<double>(type: "double precision", nullable: false),
|
RoomPrice = table.Column<double>(type: "double precision", nullable: false),
|
||||||
|
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||||
AdministratorId = table.Column<int>(type: "integer", nullable: false),
|
AdministratorId = table.Column<int>(type: "integer", nullable: false),
|
||||||
MealPlanId = table.Column<int>(type: "integer", nullable: true)
|
MealPlanId = table.Column<int>(type: "integer", nullable: true)
|
||||||
},
|
},
|
@ -70,6 +70,9 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
b.Property<int>("OrganiserId")
|
b.Property<int>("OrganiserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("StartDate")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<string>("Subject")
|
b.Property<string>("Subject")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@ -326,8 +329,8 @@ namespace HotelDataBaseImplement.Migrations
|
|||||||
b.Property<int>("AdministratorId")
|
b.Property<int>("AdministratorId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("CountBeds")
|
b.Property<DateTime>("DateCreate")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int?>("MealPlanId")
|
b.Property<int?>("MealPlanId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
@ -22,6 +22,9 @@ namespace HotelDataBaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime StartDate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public int OrganiserId { get; private set; }
|
public int OrganiserId { get; private set; }
|
||||||
|
|
||||||
public virtual Organiser Organiser { get; set; }
|
public virtual Organiser Organiser { get; set; }
|
||||||
@ -56,6 +59,7 @@ namespace HotelDataBaseImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ConferenceName = model.ConferenceName,
|
ConferenceName = model.ConferenceName,
|
||||||
Subject = model.Subject,
|
Subject = model.Subject,
|
||||||
|
StartDate = model.StartDate,
|
||||||
OrganiserId = model.OrganiserId,
|
OrganiserId = model.OrganiserId,
|
||||||
Participants = model.ConferenceParticipants.Select(x => new ConferenceParticipant
|
Participants = model.ConferenceParticipants.Select(x => new ConferenceParticipant
|
||||||
{
|
{
|
||||||
@ -68,6 +72,7 @@ namespace HotelDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
ConferenceName = model.ConferenceName;
|
ConferenceName = model.ConferenceName;
|
||||||
Subject = model.Subject;
|
Subject = model.Subject;
|
||||||
|
StartDate = model.StartDate;
|
||||||
OrganiserId = model.OrganiserId;
|
OrganiserId = model.OrganiserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +81,7 @@ namespace HotelDataBaseImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
ConferenceName = ConferenceName,
|
ConferenceName = ConferenceName,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
|
StartDate= StartDate,
|
||||||
OrganiserId = OrganiserId,
|
OrganiserId = OrganiserId,
|
||||||
ConferenceParticipants = ConferenceParticipants
|
ConferenceParticipants = ConferenceParticipants
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
using HotelContracts.BindingModels;
|
using HotelContracts.BindingModels;
|
||||||
using HotelContracts.ViewModels;
|
using HotelContracts.ViewModels;
|
||||||
using HotelDataModels.Models;
|
using HotelDataModels.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace HotelDataBaseImplement.Models
|
namespace HotelDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
@ -17,9 +13,9 @@ namespace HotelDataBaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int RoomNumber { get; set; }
|
public int RoomNumber { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int CountBeds { get; set; }
|
|
||||||
[Required]
|
|
||||||
public double RoomPrice { get; set; }
|
public double RoomPrice { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public int AdministratorId { get; private set; }
|
public int AdministratorId { get; private set; }
|
||||||
public int? MealPlanId { get; private set; }
|
public int? MealPlanId { get; private set; }
|
||||||
@ -54,8 +50,8 @@ namespace HotelDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
RoomNumber = model.RoomNumber,
|
RoomNumber = model.RoomNumber,
|
||||||
CountBeds = model.CountBeds,
|
|
||||||
RoomPrice = model.RoomPrice,
|
RoomPrice = model.RoomPrice,
|
||||||
|
DateCreate = model.DateCreate,
|
||||||
AdministratorId = model.AdministratorId,
|
AdministratorId = model.AdministratorId,
|
||||||
MealPlanId = model.MealPlanId,
|
MealPlanId = model.MealPlanId,
|
||||||
Dinners = model.RoomDinners.Select(x => new RoomDinner
|
Dinners = model.RoomDinners.Select(x => new RoomDinner
|
||||||
@ -68,8 +64,8 @@ namespace HotelDataBaseImplement.Models
|
|||||||
public void Update(RoomBindingModel model)
|
public void Update(RoomBindingModel model)
|
||||||
{
|
{
|
||||||
RoomNumber = model.RoomNumber;
|
RoomNumber = model.RoomNumber;
|
||||||
CountBeds = model.CountBeds;
|
|
||||||
RoomPrice = model.RoomPrice;
|
RoomPrice = model.RoomPrice;
|
||||||
|
DateCreate = model.DateCreate;
|
||||||
AdministratorId = model.AdministratorId;
|
AdministratorId = model.AdministratorId;
|
||||||
MealPlanId = model.MealPlanId;
|
MealPlanId = model.MealPlanId;
|
||||||
}
|
}
|
||||||
@ -78,8 +74,8 @@ namespace HotelDataBaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
RoomNumber = RoomNumber,
|
RoomNumber = RoomNumber,
|
||||||
CountBeds = CountBeds,
|
|
||||||
RoomPrice = RoomPrice,
|
RoomPrice = RoomPrice,
|
||||||
|
DateCreate = DateCreate,
|
||||||
AdministratorId = AdministratorId,
|
AdministratorId = AdministratorId,
|
||||||
MealPlanId = MealPlanId,
|
MealPlanId = MealPlanId,
|
||||||
RoomDinners = RoomDinners
|
RoomDinners = RoomDinners
|
||||||
|
@ -10,7 +10,7 @@ namespace HotelDataModels.Models
|
|||||||
{
|
{
|
||||||
int RoomNumber { get; }
|
int RoomNumber { get; }
|
||||||
double RoomPrice { get; }
|
double RoomPrice { get; }
|
||||||
DateTime? DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
int AdministratorId { get; }
|
int AdministratorId { get; }
|
||||||
public Dictionary<int, IDinnerModel> RoomDinners { get; }
|
public Dictionary<int, IDinnerModel> RoomDinners { get; }
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ namespace HotelRestApi.Controllers
|
|||||||
var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId });
|
var elem = _mealPlan.ReadElement(new MealPlanSearchModel { Id = mealPlanId });
|
||||||
if (elem == null)
|
if (elem == null)
|
||||||
return null;
|
return null;
|
||||||
return Tuple.Create(elem, elem.MealPlanParticipants.Select(x => Tuple.Create(x.Value.ParticipantFIO, x.Value.Number)).ToList(), context.Rooms.Where(x => x.MealPlanId == elem.Id).Select(x => Tuple.Create(x.RoomNumber, x.CountBeds)).ToList());
|
return Tuple.Create(elem, elem.MealPlanParticipants.Select(x => Tuple.Create(x.Value.ParticipantFIO, x.Value.Number)).ToList(), context.Rooms.Where(x => x.MealPlanId == elem.Id).Select(x => Tuple.Create(x.RoomNumber, x.DateCreate.Year)).ToList());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user