Skip to content

Commit

Permalink
New - Ajout de la désactivation d'un point de vente / mode de livraison
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Nov 5, 2020
1 parent f7cecbe commit a73436c
Show file tree
Hide file tree
Showing 15 changed files with 3,330 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public CreateDeliveryModeCommand(RequestUser requestUser) : base(requestUser)
public int LockOrderHoursBeforeDelivery { get; set; }
public LocationAddressInput Address { get; set; }
public IEnumerable<TimeSlotGroupInput> OpeningHours { get; set; }
public bool Available { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public UpdateDeliveryModeCommand(RequestUser requestUser) : base(requestUser)
public int LockOrderHoursBeforeDelivery { get; set; }
public LocationAddressInput Address { get; set; }
public IEnumerable<TimeSlotGroupInput> OpeningHours { get; set; }
public bool Available { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public async Task<Result<Guid>> Handle(CreateDeliveryModeCommand request, Cancel
var entity = new DeliveryMode(Guid.NewGuid(), request.Kind, producer, request.LockOrderHoursBeforeDelivery, deliveryModeAddress, openingHours, request.Name, request.Description);
entity.SetAvailability(request.Available);
if (request.Kind == DeliveryKind.Collective || request.Kind == DeliveryKind.Farm || request.Kind == DeliveryKind.Market)
producer.CanDirectSell = true;
Expand All @@ -70,6 +72,7 @@ public async Task<Result<bool>> Handle(UpdateDeliveryModeCommand request, Cancel
var entity = await _context.GetByIdAsync<DeliveryMode>(request.Id, token);
entity.SetName(request.Name);
entity.SetAvailability(request.Available);
entity.SetDescription(request.Description);
entity.SetLockOrderHoursBeforeDelivery(request.LockOrderHoursBeforeDelivery);
entity.SetKind(request.Kind);
Expand Down
1 change: 1 addition & 0 deletions Sheaft.Application.Models/Dto/DeliveryDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class DeliveryDto
public Guid Id { get; set; }
public DeliveryKind Kind { get; set; }
public string Name { get; set; }
public bool Available { get; set; }
public AddressDto Address { get; set; }
public IEnumerable<DeliveryHourDto> DeliveryHours { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions Sheaft.Application.Models/Dto/DeliveryModeDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class DeliveryModeDto
public int LockOrderHoursBeforeDelivery { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool Available { get; set; }
public AddressDto Address { get; set; }
public UserDto Producer { get; set; }
public IEnumerable<TimeSlotDto> OpeningHours { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class CreateDeliveryModeInput
public string Name { get; set; }
public string Description { get; set; }
public DeliveryKind Kind { get; set; }
public bool Available { get; set; }
public int? LockOrderHoursBeforeDelivery { get; set; }
public LocationAddressInput Address { get; set; }
public IEnumerable<TimeSlotGroupInput> OpeningHours { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions Sheaft.Application.Queries/DeliveryQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public IQueryable<DeliveryModeDto> GetDeliveries(RequestUser currentUser)
public async Task<IEnumerable<ProducerDeliveriesDto>> GetProducersDeliveriesAsync(IEnumerable<Guid> producerIds, IEnumerable<DeliveryKind> kinds, DateTimeOffset currentDate, RequestUser currentUser, CancellationToken token)
{
var list = new List<ProducerDeliveriesDto>();
var deliveriesMode = await _context.FindAsync<DeliveryMode>(d => producerIds.Contains(d.Producer.Id) && kinds.Contains(d.Kind), token);
var deliveriesMode = await _context.FindAsync<DeliveryMode>(d => d.Available && producerIds.Contains(d.Producer.Id) && kinds.Contains(d.Kind), token);

var deliveriesProducerIds = deliveriesMode.Select(c => c.Producer.Id).Distinct();
var producerDistinctIds = producerIds.Distinct();
Expand All @@ -68,6 +68,7 @@ public async Task<IEnumerable<ProducerDeliveriesDto>> GetProducersDeliveriesAsyn
{
Id = deliveryMode.Id,
Kind = deliveryMode.Kind,
Available = deliveryMode.Available,
Address = deliveryMode.Address != null ? new AddressDto
{
City = deliveryMode.Address.City,
Expand All @@ -92,7 +93,7 @@ public async Task<IEnumerable<ProducerDeliveriesDto>> GetProducersDeliveriesAsyn
public async Task<IEnumerable<ProducerDeliveriesDto>> GetStoreDeliveriesForProducersAsync(Guid storeId, IEnumerable<Guid> producerIds, IEnumerable<DeliveryKind> kinds, DateTimeOffset currentDate, RequestUser currentUser, CancellationToken token)
{
var list = new List<ProducerDeliveriesDto>();
var agreements = await _context.FindAsync<Agreement>(d => producerIds.Contains(d.Delivery.Producer.Id) && d.Store.Id == storeId && d.Status == AgreementStatus.Accepted && kinds.Contains(d.Delivery.Kind), token);
var agreements = await _context.FindAsync<Agreement>(d => d.Delivery.Available && producerIds.Contains(d.Delivery.Producer.Id) && d.Store.Id == storeId && d.Status == AgreementStatus.Accepted && kinds.Contains(d.Delivery.Kind), token);

var agreementProducerIds = agreements.Select(c => c.Delivery.Producer.Id).Distinct();
var producerDistinctIds = producerIds.Distinct();
Expand Down Expand Up @@ -124,6 +125,7 @@ public async Task<IEnumerable<ProducerDeliveriesDto>> GetStoreDeliveriesForProdu
{
Id = agreement.Delivery.Id,
Kind = agreement.Delivery.Kind,
Available = agreement.Delivery.Available,
Address = agreement.Delivery.Address != null ? new AddressDto
{
City = agreement.Delivery.Address.City,
Expand Down
11 changes: 11 additions & 0 deletions Sheaft.Domain/DeliveryMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public DeliveryMode(Guid id, DeliveryKind kind, Producer producer, int lockOrder
public int LockOrderHoursBeforeDelivery { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public bool Available { get; private set; }
public virtual DeliveryAddress Address { get; private set; }
public virtual Producer Producer { get; private set; }
public virtual IReadOnlyCollection<TimeSlotHour> OpeningHours => _openingHours?.AsReadOnly();
Expand Down Expand Up @@ -64,6 +65,11 @@ public void SetDescription(string description)
Description = description;
}

public void SetAvailability(bool available)
{
Available = available;
}

public void SetName(string name)
{
Name = name;
Expand All @@ -73,5 +79,10 @@ public void SetKind(DeliveryKind kind)
{
Kind = kind;
}

public void SetAvailability(object available)
{
throw new NotImplementedException();
}
}
}
1 change: 1 addition & 0 deletions Sheaft.GraphQL.Types/Inputs/CreateDeliveryModeInputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ protected override void Configure(IInputObjectTypeDescriptor<CreateDeliveryModeI
descriptor.Field(c => c.Description);
descriptor.Field(c => c.Kind);
descriptor.Field(c => c.Name);
descriptor.Field(c => c.Available);
descriptor.Field(c => c.LockOrderHoursBeforeDelivery);

descriptor.Field(c => c.Address)
Expand Down
1 change: 1 addition & 0 deletions Sheaft.GraphQL.Types/Inputs/UpdateDeliveryModeInputType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ protected override void Configure(IInputObjectTypeDescriptor<UpdateDeliveryModeI
{
descriptor.Field(c => c.Description);
descriptor.Field(c => c.Kind);
descriptor.Field(c => c.Available);
descriptor.Field(c => c.LockOrderHoursBeforeDelivery);

descriptor.Field(c => c.Id)
Expand Down
1 change: 1 addition & 0 deletions Sheaft.GraphQL.Types/Outputs/DeliveryModeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protected override void Configure(IObjectTypeDescriptor<DeliveryModeDto> descrip
descriptor.Field(c => c.LockOrderHoursBeforeDelivery);
descriptor.Field(c => c.Kind);
descriptor.Field(c => c.Name);
descriptor.Field(c => c.Available);
descriptor.Field(c => c.Description);

descriptor.Field(c => c.Address)
Expand Down
2 changes: 1 addition & 1 deletion Sheaft.GraphQL.Types/Outputs/DeliveryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected override void Configure(IObjectTypeDescriptor<DeliveryDto> descriptor)
{
descriptor.Field(c => c.Id).Type<NonNullType<IdType>>();
descriptor.Field(c => c.Kind);

descriptor.Field(c => c.Available);
descriptor.Field(c => c.Address)
.Type<AddressType>();

Expand Down
Loading

0 comments on commit a73436c

Please sign in to comment.