Skip to content
Open
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
6 changes: 3 additions & 3 deletions KebPOS/DbContexts/KebabContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ internal class KebabContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Data source to be replaced with config connection string.
string projPath = Path.GetFullPath(@"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\");
// optionsBuilder.UseSqlite($"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\Kebab.db");
optionsBuilder.UseSqlite($"Data Source=Kebab.db;");
string projPath = Path.GetFullPath(@"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\");
// optionsBuilder.UseSqlite($"C:\\Users\\sipah\\Desktop\\serdar\\projeler\\pointofsle\\CONSOLE.PointOfSale\\KebPOS\\Kebab.db");
optionsBuilder.UseSqlite($"Data Source=Kebab.db;");
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
Expand Down
2 changes: 1 addition & 1 deletion KebPOS/KebabController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class KebabController
{
public void UpdateProductName(Product product, string newProductName)
{
using var db = new KebabContext();
using var db = new KebabContext();
product.Name = newProductName;
db.Entry(product).State = EntityState.Modified;
db.SaveChanges();
Expand Down
4 changes: 2 additions & 2 deletions KebPOS/Services/ProductService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static void InsertProduct()
{
bool exit = false;
bool addNewProduct = true;

while (addNewProduct)
{
bool isDuplicate = true;
Expand All @@ -23,7 +23,7 @@ internal static void InsertProduct()
var product = new Product();
product = new Product();


while (!nameValid || isDuplicate)
{
Console.Clear();
Expand Down
27 changes: 19 additions & 8 deletions KebPOS/UserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ internal void ManageReportsMenu()
private void UpdateProduct()
{
var products = _kebabController.GetProducts();
var productsNameList=products.Select(x => x.Name).ToList();
var productsNameList = products.Select(x => x.Name).ToList();
var selectedProductName = AnsiConsole.Prompt(new SelectionPrompt<string>().
Title("[Purple]Select product[/]").
AddChoices(productsNameList));
Product productToUpdate=products.Single(x=> x.Name==selectedProductName);
Product productToUpdate = products.Single(x => x.Name == selectedProductName);
var propertyToUpdate = AnsiConsole.Prompt(new SelectionPrompt<ProductProperties>()
.Title("[Purple]Select property to update[/]")
.Title("[Purple]Select property to update[/]")
.AddChoices(
ProductProperties.Name,
ProductProperties.Description,
ProductProperties.Price,
ProductProperties.MainMenu));

switch(propertyToUpdate)
switch (propertyToUpdate)
{
case ProductProperties.Name:
UpdateProductName(productToUpdate);
Expand Down Expand Up @@ -179,8 +179,19 @@ private void UpdateProductDescription(Product productToUpdate)

private void UpdateProductPrice(Product productToUpdate)
{
AnsiConsole.Markup($"[Blue]Current price:[/] {productToUpdate.Price}");
decimal newPrice = AnsiConsole.Ask<decimal>("[Yellow]Enter new price:[/] ");
AnsiConsole.Markup($"[Blue]Current price:[/] {productToUpdate.Price}\n");
decimal newPrice = AnsiConsole.Prompt(
new TextPrompt<decimal>("[Yellow]Enter new price:[/] ")
.ValidationErrorMessage("Not valid input")
.Validate(price =>
{
return price switch
{
<= 0 => ValidationResult.Error("Price must be greater than zero"),
_ => ValidationResult.Success(),
};
}));

_kebabController.UpdateProductPrice(productToUpdate, newPrice);
}
private void DeleteOrder() // Buray� kodluyorsun
Expand Down Expand Up @@ -413,7 +424,7 @@ public void DisplayProducts(List<ProductDto> products)

AnsiConsole.Write(productTable);
}
// added for testing
// added for testing
public void DisplayProducts(List<Product> products)
{
var productTable = new Table().Centered();
Expand Down Expand Up @@ -443,7 +454,7 @@ public void DisplayProducts(List<Product> products)

AnsiConsole.Write(productTable);
}
//end add
//end add
public void DisplayOrders(List<Order> orders)
{
var orderTable = new Table().Centered();
Expand Down