Add an equipment in the gear
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
public int MinSize { get; set; }
|
public int MinSize { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string ReserveCanopy { get; set; }
|
public string ReserveCanopy { get; set; }
|
||||||
|
public string Equipment { get; set; }
|
||||||
|
|
||||||
public User User { get; set; }
|
public User User { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
#region Public Methods
|
#region Public Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new gear item to the system.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newGear">The Gear entity containing the new gear data.</param>
|
||||||
public void AddNewGear(Gear newGear)
|
public void AddNewGear(Gear newGear)
|
||||||
{
|
{
|
||||||
newGear.User = _identityService.ConnectedUser;
|
newGear.User = _identityService.ConnectedUser;
|
||||||
@@ -32,11 +36,11 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
var userId = _identityService.ConnectedUser.Id;
|
var userId = _identityService.ConnectedUser.Id;
|
||||||
_cacheService.Delete(CacheType.Gear, userId: userId);
|
_cacheService.Delete(CacheType.Gear, userId: userId);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Adds a new gear item to the system.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newGear">The Gear entity containing the new gear data.</param>
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds rental gear to the system for a new user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newUser">The new user for whom rental gear should be added.</param>
|
||||||
public void AddRentalGear(User newUser)
|
public void AddRentalGear(User newUser)
|
||||||
{
|
{
|
||||||
var rentalGear = new Gear
|
var rentalGear = new Gear
|
||||||
@@ -48,25 +52,26 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
MaxSize = 280,
|
MaxSize = 280,
|
||||||
MinSize = 190,
|
MinSize = 190,
|
||||||
ReserveCanopy = "?",
|
ReserveCanopy = "?",
|
||||||
|
Equipment = "RAS",
|
||||||
User = newUser
|
User = newUser
|
||||||
};
|
};
|
||||||
|
|
||||||
_gearRepository.Add(rentalGear);
|
_gearRepository.Add(rentalGear);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Adds rental gear to the system for a new user.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newUser">The new user for whom rental gear should be added.</param>
|
|
||||||
|
|
||||||
public void DeleteGearById(int id)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a gear item by its ID.
|
/// Deletes a gear item by its ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The gear ID to delete.</param>
|
/// <param name="id">The gear ID to delete.</param>
|
||||||
|
public void DeleteGearById(int id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves all gear items.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A collection of Gear entities containing all gear data.</returns>
|
||||||
public IEnumerable<Gear> GetAllGears()
|
public IEnumerable<Gear> GetAllGears()
|
||||||
{
|
{
|
||||||
var userId = _identityService.ConnectedUser.Id;
|
var userId = _identityService.ConnectedUser.Id;
|
||||||
@@ -78,34 +83,30 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
return _cacheService.Get<IEnumerable<Gear>>(CacheType.Gear, userId: userId);
|
return _cacheService.Get<IEnumerable<Gear>>(CacheType.Gear, userId: userId);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Retrieves all gear items.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A collection of Gear entities containing all gear data.</returns>
|
|
||||||
|
|
||||||
public Gear GetGearById(int id)
|
|
||||||
{
|
|
||||||
var allGears = GetAllGears();
|
|
||||||
return allGears.Single(g => g.Id == id);
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a gear item by its ID.
|
/// Retrieves a gear item by its ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The gear ID to retrieve.</param>
|
/// <param name="id">The gear ID to retrieve.</param>
|
||||||
/// <returns>A Gear entity containing the gear details.</returns>
|
/// <returns>A Gear entity containing the gear details.</returns>
|
||||||
|
public Gear GetGearById(int id)
|
||||||
public bool UpdateGear(int id, Gear gear)
|
|
||||||
{
|
{
|
||||||
gear.Id = id;
|
var allGears = GetAllGears();
|
||||||
|
return allGears.Single(g => g.Id == id);
|
||||||
return _gearRepository.Update(gear);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates an existing gear item.
|
/// Updates an existing gear item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The gear ID to update.</param>
|
/// <param name="id">The gear ID to update.</param>
|
||||||
/// <param name="gear">Gear entity containing the updated gear data.</param>
|
/// <param name="gear">Gear entity containing the updated gear data.</param>
|
||||||
/// <returns>True if the update was successful, false otherwise.</returns>
|
/// <returns>True if the update was successful, false otherwise.</returns>
|
||||||
|
public bool UpdateGear(int id, Gear gear)
|
||||||
|
{
|
||||||
|
gear.Id = id;
|
||||||
|
|
||||||
|
return _gearRepository.Update(gear);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,7 @@
|
|||||||
public string MainCanopy { get; set; }
|
public string MainCanopy { get; set; }
|
||||||
|
|
||||||
public string ReserveCanopy { get; set; }
|
public string ReserveCanopy { get; set; }
|
||||||
|
|
||||||
|
public string Equipment { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,5 +17,7 @@
|
|||||||
public string MainCanopy { get; set; }
|
public string MainCanopy { get; set; }
|
||||||
|
|
||||||
public string ReserveCanopy { get; set; }
|
public string ReserveCanopy { get; set; }
|
||||||
|
|
||||||
|
public string Equipment { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user