едем на рыбалку
This commit is contained in:
parent
454dd5c594
commit
4a2e6ac004
@ -6,7 +6,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TravelCompanyContracts.SearchModels.Guarantor
|
||||
{
|
||||
internal class TripSearchModel
|
||||
public class TripSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string TripName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime TripDate { get; set; }
|
||||
public int GuarantorId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.SearchModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
|
||||
@ -18,10 +19,10 @@ namespace TravelCompanyContracts.StoragesModels.Guarantor
|
||||
|
||||
GuarantorViewModel? GetElement(GuarantorSearchModel model);
|
||||
|
||||
GuarantorViewModel? Insert(GuarantorSearchModel model);
|
||||
GuarantorViewModel? Insert(GuarantorBindingModel model);
|
||||
|
||||
GuarantorViewModel? Update(GuarantorSearchModel model);
|
||||
GuarantorViewModel? Update(GuarantorBindingModel model);
|
||||
|
||||
GuarantorViewModel? Delete(GuarantorSearchModel model);
|
||||
GuarantorViewModel? Delete(GuarantorBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.SearchModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
|
||||
@ -18,10 +18,10 @@ namespace TravelCompanyContracts.StoragesModels.Guarantor
|
||||
|
||||
GuideViewModel? GetElement(GuideSearchModel model);
|
||||
|
||||
GuideViewModel? Insert(GuideSearchModel model);
|
||||
GuideViewModel? Insert(GuideBindingModel model);
|
||||
|
||||
GuideViewModel? Update(GuideSearchModel model);
|
||||
GuideViewModel? Update(GuideBindingModel model);
|
||||
|
||||
GuideViewModel? Delete(GuideSearchModel model);
|
||||
GuideViewModel? Delete(GuideBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.SearchModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
|
||||
@ -17,10 +18,10 @@ namespace TravelCompanyContracts.StoragesModels.Guarantor
|
||||
|
||||
PlaceViewModel? GetElement(PlaceSearchModel model);
|
||||
|
||||
PlaceViewModel? Insert(PlaceSearchModel model);
|
||||
PlaceViewModel? Insert(PlaceBindingModel model);
|
||||
|
||||
PlaceViewModel? Update(PlaceSearchModel model);
|
||||
PlaceViewModel? Update(PlaceBindingModel model);
|
||||
|
||||
PlaceViewModel? Delete(PlaceSearchModel model);
|
||||
PlaceViewModel? Delete(PlaceBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,24 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.SearchModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
|
||||
namespace TravelCompanyContracts.StoragesModels.Guarantor
|
||||
{
|
||||
internal class ITripStorage
|
||||
public interface ITripStorage
|
||||
{
|
||||
List<TripViewModel> GetFullList();
|
||||
|
||||
List<TripViewModel> GetFilteredList(TripSearchModel model);
|
||||
|
||||
TripViewModel? GetElement(TripSearchModel model);
|
||||
|
||||
TripViewModel? Insert(TripBindingModel model);
|
||||
|
||||
TripViewModel? Update(TripBindingModel model);
|
||||
|
||||
PlaceViewModel? Delete(TripBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,7 @@ namespace TravelCompanyContracts.ViewModels.Guarantor.ViewModels
|
||||
|
||||
[DisplayName("Цена гида")]
|
||||
public double GuidePrice { get; set; }
|
||||
|
||||
public int GuarantorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyDataModels.Models.Guarantor;
|
||||
|
||||
namespace TravelCompanyContracts.ViewModels.Guarantor.ViewModels
|
||||
{
|
||||
internal class TripViewModel
|
||||
// Отображение информации о поручителях
|
||||
public class TripViewModel : ITripModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название поездки")]
|
||||
public string TripName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата поездки")]
|
||||
public DateTime TripDate { get; set; } = DateTime.Now;
|
||||
|
||||
public int GuarantorId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -36,17 +36,6 @@ namespace TravelCompanyDatabaseImplement.Models
|
||||
//[ForeignKey("GuarantorId")]
|
||||
//public virtual List<> { get; set; } = new();
|
||||
|
||||
public GuarantorViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
MobilePhone = MobilePhone
|
||||
};
|
||||
|
||||
public static Guarantor Create(GuarantorBindingModel model)
|
||||
{
|
||||
return new Guarantor()
|
||||
@ -70,5 +59,16 @@ namespace TravelCompanyDatabaseImplement.Models
|
||||
Password = model.Password;
|
||||
MobilePhone = model.MobilePhone;
|
||||
}
|
||||
public GuarantorViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
MobilePhone = MobilePhone
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,76 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
using TravelCompanyDataModels.Models.Guarantor;
|
||||
|
||||
namespace TravelCompanyDatabaseImplement.Models
|
||||
{
|
||||
internal class Guide
|
||||
public class Guide : IGuideModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string GuideFIO { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double GuidePrice { get; set; }
|
||||
|
||||
[Required]
|
||||
public int GuarantorId { get; set; }
|
||||
|
||||
[DeleteBehavior(DeleteBehavior.Restrict)]
|
||||
public virtual Guarantor Guarantor { get; set; }
|
||||
|
||||
//[ForeignKey("GuideId")]
|
||||
//public virtual List<> { get; set; } = new();
|
||||
|
||||
//[ForeignKey("GuideId")]
|
||||
//public virtual List<> { get; set; } = new();
|
||||
|
||||
public static Guide? Create(GuideBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Guide()
|
||||
{
|
||||
Id = model.Id,
|
||||
GuideFIO = model.GuideFIO,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
GuidePrice = model.GuidePrice,
|
||||
GuarantorId = model.GuarantorId,
|
||||
};
|
||||
}
|
||||
public void Update(GuideBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GuideFIO = model.GuideFIO;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
GuidePrice = model.GuidePrice;
|
||||
GuarantorId = model.GuarantorId;
|
||||
}
|
||||
|
||||
public GuideViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
GuideFIO = GuideFIO,
|
||||
PhoneNumber = PhoneNumber,
|
||||
GuidePrice = GuidePrice,
|
||||
GuarantorId = GuarantorId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,110 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
using TravelCompanyDataModels.Models.Contractor;
|
||||
using TravelCompanyDataModels.Models.Guarantor;
|
||||
|
||||
namespace TravelCompanyDatabaseImplement.Models
|
||||
{
|
||||
internal class Place
|
||||
public class Place : IPlaceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string NamePlace { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string DescriptionPlace { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int GuarantorID { get; set; }
|
||||
|
||||
[DeleteBehavior(DeleteBehavior.Restrict)]
|
||||
public virtual Guarantor Guarantor { get; set; }
|
||||
}
|
||||
|
||||
private Dictionary<int, ITripModel>? _placeTrips = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, ITripModel> PlaceTrips
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_placeTrips == null)
|
||||
{
|
||||
_placeTrips = Trips
|
||||
.ToDictionary(recPC => recPC.TourId, recPC => recPC.Tour as ITripModel);
|
||||
}
|
||||
return _placeTrips;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("ExcursionGroupId")]
|
||||
public virtual List<PlaceTrip> Trips { get; set; } = new();
|
||||
|
||||
public static Place? Create(TravelCompanyDatabase context, PlaceBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ExcursionGroup()
|
||||
{
|
||||
Id = model.Id,
|
||||
ExcursionGroupName = model.ExcursionGroupName,
|
||||
PeopleAmount = model.PeopleAmount,
|
||||
ContractorID = model.ContractorID,
|
||||
Tours = model.ExcursionGroupTours.Select(x => new ExcursionGroupTour
|
||||
{
|
||||
Tour = context.Tours.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(ExcursionGroupBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ExcursionGroupName = model.ExcursionGroupName;
|
||||
PeopleAmount = model.PeopleAmount;
|
||||
}
|
||||
|
||||
public ExcursionGroupViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ExcursionGroupName = ExcursionGroupName,
|
||||
PeopleAmount = PeopleAmount,
|
||||
ContractorID = ContractorID,
|
||||
ExcursionGroupTours = ExcursionGroupTours
|
||||
};
|
||||
|
||||
public void UpdateTours(TravelCompanyDatabase context, ExcursionGroupBindingModel model)
|
||||
{
|
||||
var excursionGroupTours = context.ExcursionGroupTours.Where(rec => rec.ExcursionGroupId == model.Id).ToList();
|
||||
if (excursionGroupTours != null && excursionGroupTours.Count > 0)
|
||||
{
|
||||
context.ExcursionGroupTours.RemoveRange(excursionGroupTours.Where(rec => !model.ExcursionGroupTours.ContainsKey(rec.TourId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
var excursionGroup = context.ExcursionGroups.First(x => x.Id == Id);
|
||||
foreach (var et in model.ExcursionGroupTours)
|
||||
{
|
||||
context.ExcursionGroupTours.Add(new ExcursionGroupTour
|
||||
{
|
||||
ExcursionGroup = excursionGroup,
|
||||
Tour = context.Tours.First(x => x.Id == et.Key)
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_excursionGroupTours = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,69 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TravelCompanyContracts.BindingModels.Guarantor;
|
||||
using TravelCompanyContracts.ViewModels.Guarantor.ViewModels;
|
||||
using TravelCompanyDataModels.Models.Guarantor;
|
||||
|
||||
namespace TravelCompanyDatabaseImplement.Models
|
||||
{
|
||||
internal class Trip
|
||||
public class Trip : ITripModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string TripName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime TripDate { get; set; }
|
||||
|
||||
[Required]
|
||||
public int GuarantorId { get; set; }
|
||||
|
||||
[DeleteBehavior(DeleteBehavior.Restrict)]
|
||||
public virtual Guarantor Guarantor { get; set; }
|
||||
|
||||
[ForeignKey("TripId")]
|
||||
public virtual List<GuideTrip> Guides { get; set; } = new();
|
||||
|
||||
[ForeignKey("TripId")]
|
||||
public virtual List<PlaceTrip> PlaceTrips { get; set; } = new();
|
||||
|
||||
public static Trip? Create(TripBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Trip()
|
||||
{
|
||||
Id = model.Id,
|
||||
TripName = model.TripName,
|
||||
TripDate = model.TripDate,
|
||||
GuarantorId = model.GuarantorId,
|
||||
};
|
||||
}
|
||||
public void Update(TripBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TripName = model.TripName;
|
||||
TripDate = model.TripDate;
|
||||
}
|
||||
|
||||
public TripViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
TripName = TripName,
|
||||
TripDate = TripDate,
|
||||
GuarantorId = GuarantorId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user