Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing of active without changing of name #260

Merged
merged 6 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions coffeecard/CoffeeCard.Library/Services/v2/MenuItemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public async Task<IEnumerable<MenuItemResponse>> GetAllMenuItemsAsync()
.Select(p => new MenuItemResponse
{
Id = p.Id,
Name = p.Name
Name = p.Name,
Active = p.Active
})
.ToListAsync();
}
Expand All @@ -52,7 +53,8 @@ public async Task<MenuItemResponse> AddMenuItemAsync(AddMenuItemRequest newMenuI
var result = new MenuItemResponse
{
Id = menuItem.Id,
Name = menuItem.Name
Name = menuItem.Name,
Active = true
};

return result;
Expand All @@ -75,7 +77,7 @@ public async Task<MenuItemResponse> UpdateMenuItemAsync(int id, UpdateMenuItemRe
}

var nameExists = await CheckMenuItemNameExists(changedMenuItem.Name);
if (nameExists)
if (changedMenuItem.Name != menuItem.Name && nameExists)
{
throw new ConflictException($"Menu item already exists with name {changedMenuItem.Name}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ namespace CoffeeCard.Models.DataTransferObjects.v2.Products
/// <summary>
/// Represents a menu item that can be redeemed with a ticket
/// </summary>
/// <example>
/// {
/// "id": 1,
/// "name": "Cappuccino",
/// }
/// </example>
public class MenuItemResponse
{
/// <summary>
Expand All @@ -34,6 +28,7 @@ public class MenuItemResponse
/// </summary>
/// <value>Menu item active</value>
/// <example>true</example>
[Required]
public bool Active { get; set; }
}
}
2 changes: 1 addition & 1 deletion coffeecard/CoffeeCard.Models/Entities/MenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public class MenuItem
/// <summary>
/// Whether or not this menu item is active
/// </summary>
public bool Active { get; set; }
public bool Active { get; set; } = true;
}
2 changes: 1 addition & 1 deletion coffeecard/CoffeeCard.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
}
]
}
}
}
Loading