2024-04-28 23:08:12 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using TravelAgencyContracts.BindingModels;
|
|
|
|
|
using TravelAgencyContracts.ViewModels;
|
|
|
|
|
using TravelAgencyDataModels.Models;
|
|
|
|
|
|
|
|
|
|
namespace TravelAgencyDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Place : IPlaceModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string PlaceName { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public string PlaceAddress { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ForeignKey("PlaceId")]
|
|
|
|
|
public virtual List<TripPlace> Trips { get; set; } = new();
|
|
|
|
|
|
2024-05-29 08:46:50 +04:00
|
|
|
|
[ForeignKey("PlaceId")]
|
|
|
|
|
public virtual List<Excursion> Excursions { get; set; } = new();
|
|
|
|
|
|
2024-05-29 13:06:49 +04:00
|
|
|
|
[ForeignKey("PlaceId")]
|
|
|
|
|
public virtual List<ExcursionGroupPlace> ExcursionGroups { get; set; } = new();
|
|
|
|
|
|
2024-04-28 23:08:12 +04:00
|
|
|
|
public static Place? Create(PlaceBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Place()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
PlaceName = model.PlaceName,
|
2024-05-29 08:46:50 +04:00
|
|
|
|
PlaceAddress = model.PlaceAddress
|
2024-04-28 23:08:12 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(PlaceBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PlaceName = model.PlaceName;
|
|
|
|
|
PlaceAddress = model.PlaceAddress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PlaceViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
PlaceName = PlaceName,
|
2024-05-29 08:46:50 +04:00
|
|
|
|
PlaceAddress = PlaceAddress
|
2024-04-28 23:08:12 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|