Skip to content

Commit

Permalink
feat(weapons): remove weapon lot
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Sep 7, 2021
1 parent f5a9b62 commit af3321f
Show file tree
Hide file tree
Showing 13 changed files with 1,669 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public class CreateWeaponRequest
[MaxLength(256, ErrorMessage = "El número de serie del arma no debe tener más de 256 caracteres.")]
public string Series { get; set; }

[Required(ErrorMessage = "El lote del arma es requerido.")]
[MaxLength(256, ErrorMessage = "El lote del arma no debe tener más de 256 caracteres.")]
public string Lot { get; set; }

[Required(ErrorMessage = "El número de proveedores del arma es requerido.")]
public int NumberOfProviders { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public class UpdateWeaponRequest
[MaxLength(256, ErrorMessage = "El número de serie del arma no debe tener más de 256 caracteres.")]
public string Series { get; set; }

[Required(ErrorMessage = "El lote del arma es requerido.")]
[MaxLength(256, ErrorMessage = "El lote del arma no debe tener más de 256 caracteres.")]
public string Lot { get; set; }

[Required(ErrorMessage = "El número de proveedores del arma es requerido.")]
public int NumberOfProviders { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ namespace Armory.Armament.Weapons.Application.Create
public class CreateWeaponCommand : Command<string>
{
public CreateWeaponCommand(string code, string type, string mark, string model, string caliber, string series,
string lot, int numberOfProviders, int providerCapacity)
int numberOfProviders, int providerCapacity)
{
Code = code;
Type = type;
Mark = mark;
Model = model;
Caliber = caliber;
Series = series;
Lot = lot;
NumberOfProviders = numberOfProviders;
ProviderCapacity = providerCapacity;
}
Expand All @@ -24,7 +23,6 @@ public CreateWeaponCommand(string code, string type, string mark, string model,
public string Model { get; }
public string Caliber { get; }
public string Series { get; }
public string Lot { get; }
public int NumberOfProviders { get; }
public int ProviderCapacity { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public CreateWeaponCommandHandler(WeaponCreator creator)
public async Task<string> Handle(CreateWeaponCommand request, CancellationToken cancellationToken)
{
var weapon = await _creator.Create(request.Code, request.Type, request.Mark, request.Model, request.Caliber,
request.Series, request.Lot, request.NumberOfProviders, request.ProviderCapacity);
request.Series, request.NumberOfProviders, request.ProviderCapacity);

return weapon.Code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ public WeaponCreator(IWeaponsRepository repository)
}

public async Task<Weapon> Create(string code, string type, string mark, string model, string caliber,
string series,
string lot, int numberOfProviders, int providerCapacity)
string series, int numberOfProviders, int providerCapacity)
{
var weapon = Weapon.Create(code, type, mark, model, caliber, series, lot, numberOfProviders,
providerCapacity);
var weapon = Weapon.Create(code, type, mark, model, caliber, series, numberOfProviders, providerCapacity);
await _repository.Save(weapon);

return weapon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ namespace Armory.Armament.Weapons.Application.Update
public class UpdateWeaponCommand : Command
{
public UpdateWeaponCommand(string code, string type, string mark, string model, string caliber, string series,
string lot, int numberOfProviders, int providerCapacity)
int numberOfProviders, int providerCapacity)
{
Code = code;
Type = type;
Mark = mark;
Model = model;
Caliber = caliber;
Series = series;
Lot = lot;
NumberOfProviders = numberOfProviders;
ProviderCapacity = providerCapacity;
}
Expand All @@ -24,7 +23,6 @@ public UpdateWeaponCommand(string code, string type, string mark, string model,
public string Model { get; }
public string Caliber { get; }
public string Series { get; }
public string Lot { get; }
public int NumberOfProviders { get; }
public int ProviderCapacity { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override async Task Handle(UpdateWeaponCommand request, CancellationTo
}

await _updater.Update(weapon, request.Type, request.Mark, request.Model, request.Caliber,
request.Series, request.Lot, request.NumberOfProviders, request.ProviderCapacity);
request.Series, request.NumberOfProviders, request.ProviderCapacity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public WeaponUpdater(IWeaponsRepository repository)
}

public async Task Update(Weapon weapon, string type, string mark, string model, string caliber, string series,
string lot, int numberOfProviders, int providerCapacity)
int numberOfProviders, int providerCapacity)
{
weapon.Update(type, mark, model, caliber, series, lot, numberOfProviders, providerCapacity);
weapon.Update(type, mark, model, caliber, series, numberOfProviders, providerCapacity);
await _repository.Update(weapon);
}
}
Expand Down
13 changes: 5 additions & 8 deletions src/Armory/Armament/Weapons/Domain/Weapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Armory.Armament.Weapons.Domain
{
public class Weapon
{
public Weapon(string code, string type, string mark, string model, string caliber, string series, string lot,
public Weapon(string code, string type, string mark, string model, string caliber, string series,
int numberOfProviders, int providerCapacity)
{
Code = code;
Expand All @@ -18,7 +18,6 @@ public Weapon(string code, string type, string mark, string model, string calibe
Model = model;
Caliber = caliber;
Series = series;
Lot = lot;
NumberOfProviders = numberOfProviders;
ProviderCapacity = providerCapacity;
}
Expand All @@ -33,7 +32,6 @@ internal Weapon()
[Required] [MaxLength(256)] public string Model { get; set; }
[Required] [MaxLength(256)] public string Caliber { get; set; }
[Required] [MaxLength(256)] public string Series { get; set; }
[Required] [MaxLength(256)] public string Lot { get; set; }
[Required] public int NumberOfProviders { get; set; }
[Required] public int ProviderCapacity { get; set; }
[Required] public WeaponState State { get; set; }
Expand All @@ -52,23 +50,22 @@ public ICollection<WarMaterialDeliveryCertificateFormatWeapon> WarMaterialDelive
} =
new HashSet<WarMaterialDeliveryCertificateFormatWeapon>();

public void Update(string type, string mark, string model, string caliber, string series,
string lot, int numberOfProviders, int providerCapacity)
public void Update(string type, string mark, string model, string caliber, string series, int numberOfProviders,
int providerCapacity)
{
Type = type;
Mark = mark;
Model = model;
Caliber = caliber;
Series = series;
Lot = lot;
NumberOfProviders = numberOfProviders;
ProviderCapacity = providerCapacity;
}

public static Weapon Create(string code, string type, string mark, string model, string caliber, string series,
string lot, int numberOfProviders, int providerCapacity)
int numberOfProviders, int providerCapacity)
{
return new Weapon(code, type, mark, model, caliber, series, lot, numberOfProviders, providerCapacity);
return new Weapon(code, type, mark, model, caliber, series, numberOfProviders, providerCapacity);
}
}
}
Loading

0 comments on commit af3321f

Please sign in to comment.