Skip to content

Commit

Permalink
final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KaloyankerR committed Jan 14, 2024
1 parent 7b3d723 commit 534777c
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 79 deletions.
2 changes: 1 addition & 1 deletion FitFusion/DataAcess/OrderDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public bool CreateOrder(Order order)
command.Parameters.AddWithValue("@TotalPrice", order.Cart.TotalPrice);
AddNutriPointsToCustomer(order.Customer.Id, order.Cart.NutriPointsReward);
command.Parameters.AddWithValue("@NutriPoints", order.Cart.NutriPointsReward);
command.Parameters.AddWithValue("@Note", order.Note);
command.Parameters.AddWithValue("@Note", order.Note ?? string.Empty);

int orderId = Convert.ToInt32(command.ExecuteScalar());

Expand Down
6 changes: 4 additions & 2 deletions FitFusion/FitFusionDesktop/CRUD/ProductCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ private void btnSubmit_Click(object sender, EventArgs e)
MessageBox.Show("Product successfully created.");
Close();
}

MessageBox.Show("Please change category to be different than All.");
else
{
MessageBox.Show("Please change category to be different than All.");
}
}
catch (NullReferenceException ex)
{
Expand Down
8 changes: 5 additions & 3 deletions FitFusion/FitFusionDesktop/CRUD/ProductUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ private void btnSubmit_Click(object sender, EventArgs e)
{
Product product = DefineProduct();
_productManager.UpdateProduct(product);
MessageBox.Show("Product successfully created.");
MessageBox.Show("Product successfully updated.");
Close();
}

MessageBox.Show("Please change category to be different than All.");
else
{
MessageBox.Show("Please change category to be different than All.");
}
}
catch (NullReferenceException ex)
{
Expand Down
12 changes: 6 additions & 6 deletions FitFusion/FitFusionDesktop/Login.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 23 additions & 15 deletions FitFusion/FitFusionDesktop/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,33 @@ public Login()

private void btnLogin_Click(object sender, EventArgs e)
{
User? user = _userManager.AuthenticateUser(txtEmail.TextButton, txtPassword.TextButton);

if (user != null && user is not Customer)
try
{
Main frm = new Main(user);
this.Hide();
frm.ShowDialog();
Application.Exit();
User? user = _userManager.AuthenticateUser(txtEmail.TextButton, txtPassword.TextButton);

if (user != null && user is not Customer)
{
Main frm = new Main(user);
this.Hide();
frm.ShowDialog();
Application.Exit();
}
else
{
txtEmail.TextButton = string.Empty;
txtPassword.TextButton = string.Empty;

MessageBox.Show("Sorry, only Staff and Owners can access the desktop application!");
}
}
else
catch (DataAccessException)
{
txtEmail.TextButton = string.Empty;
txtPassword.TextButton = string.Empty;

MessageBox.Show("Incorrect login details for Staff members and Owners.");
MessageBox.Show("A problem with the database occured. Please try again later!");
}
catch
{
MessageBox.Show("Incorrect credentials. Please enter valid ones!");
}

// Owner owner = new Owner(1, "Steve", "Orlov", "[email protected]", "[email protected]", "", "Chicago", "555-555-123");
// _userManager.CreateUser(owner);


}
Expand Down
22 changes: 10 additions & 12 deletions FitFusion/FitFusionDesktop/UserControls/Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ public Users()

private void btnSearch_Click(object sender, EventArgs e)
{
switch ((Role)roleCmbBox.SelectedItem)
{
case Role.Customer:
btnRecommendations.Visible = true;
break;
default:
btnRecommendations.Visible = false;
break;
}

List<User> users = _userManager.GetAllUsers();

List<IFilter<User>> filters = new()
Expand Down Expand Up @@ -152,18 +162,6 @@ private void btnRefresh_Click(object sender, EventArgs e)

private void roleCmbBox_SelectedIndexChanged(object sender, EventArgs e)
{
Role role = (Role)roleCmbBox.SelectedItem;

switch (role)
{
case Role.Customer:
btnRecommendations.Visible = true;
break;
default:
btnRecommendations.Visible = false;
break;
}

}
}
}
3 changes: 2 additions & 1 deletion FitFusion/FitFusionWeb/Pages/Account.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class AccountModel : PageModel
public User? CurrentUser { get; set; }
private UserManager _userManager = new(new DataAcess.UserDAO());

public IActionResult OnGet()
public async Task<IActionResult> OnGet()
{
try
{
Expand All @@ -38,6 +38,7 @@ public IActionResult OnGet()
}
catch (NullReferenceException)
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToPage("/Error", new { code = 404 });
}

Expand Down
4 changes: 4 additions & 0 deletions FitFusion/FitFusionWeb/Pages/Cart.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public IActionResult OnPost()
{
return RedirectToPage("/Error", new { code = 500 });
}
catch
{
return RedirectToPage("/Error");
}

SessionHelper.SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", new ShoppingCart());
return RedirectToPage("/Message", new { message = "Successful order!" });
Expand Down
3 changes: 3 additions & 0 deletions FitFusion/FitFusionWeb/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public IActionResult OnGet(string code)
case "409":
errorMessage = "Conflict with the current state error!";
break;
case "414":
errorMessage = "No orders were made to recommend!";
break;
case "499":
errorMessage = "Not Enough Nutri Points!";
break;
Expand Down
22 changes: 2 additions & 20 deletions FitFusion/FitFusionWeb/Pages/Message.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace FitFusionWeb.Pages
public class MessageModel : PageModel
{
private readonly ILogger<ErrorModel> _logger;
public string PrimaryMessage;
public string PrimaryMessage = string.Empty;

public MessageModel(ILogger<ErrorModel> logger)
{
Expand All @@ -18,26 +18,8 @@ public IActionResult OnGet(string message)
string descriptionMessage;
switch (message)
{
case "400":
descriptionMessage = "Null reference";
break;
case "404":
descriptionMessage = "Page not found!";
break;
case "409":
descriptionMessage = "Conflict with the current state error!";
break;
case "499":
descriptionMessage = "Not Enough Nutri Points!";
break;
case "500":
descriptionMessage = "Internal Server Error! Database problem!";
break;

// TODO: Add more cases as needed

default:
descriptionMessage = "An error occurred!";
descriptionMessage = "Order created!";
break;
}

Expand Down
2 changes: 1 addition & 1 deletion FitFusion/FitFusionWeb/Pages/Products/Create.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IActionResult OnPost()
{
try
{
if (!ModelState.IsValid)
if (!ModelState.IsValid && ProductView.Category != Models.Product.Enums.Category.All)
{
TempData["Type"] = "danger";
TempData["Message"] = "Please, check the fields again!";
Expand Down
33 changes: 18 additions & 15 deletions FitFusion/FitFusionWeb/Pages/Recommendations.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@
<div class="cell">
<article class="card">
<img class="card-img" src="https://t4.ftcdn.net/jpg/04/73/25/49/360_F_473254957_bxG9yf4ly7OBO5I0O5KABlN930GwaMQz.jpg" alt="@Model.SystemRecommendation.Title">

<div class="card-body">
<h2 class="card-title">@Model.SystemRecommendation.Title</h2>
<p class="card-description">@Model.SystemRecommendation.Description</p>
<p class="card-price">@Model.SystemRecommendation.Price</p>
</div>

<a class="button primary btnElement" href="./Product/@Model.SystemRecommendation.Id">View product</a>
</article>
</div>

<h1>Merchant recommendation</h1>
<div class="cell">
<article class="card">
<img class="card-img" src="https://t4.ftcdn.net/jpg/04/73/25/49/360_F_473254957_bxG9yf4ly7OBO5I0O5KABlN930GwaMQz.jpg" alt="@Model.MerchantRecommendation.Title">
@if(Model.MerchantRecommendation != null)
{
<h1>Merchant recommendation</h1>
<div class="cell">
<article class="card">
<img class="card-img" src="https://t4.ftcdn.net/jpg/04/73/25/49/360_F_473254957_bxG9yf4ly7OBO5I0O5KABlN930GwaMQz.jpg" alt="@Model.MerchantRecommendation.Title">

<div class="card-body">
<h2 class="card-title">@Model.MerchantRecommendation.Title</h2>
<p class="card-description">@Model.MerchantRecommendation.Description</p>
<p class="card-price">@Model.MerchantRecommendation.Price</p>
</div>
<div class="card-body">
<h2 class="card-title">@Model.MerchantRecommendation.Title</h2>
<p class="card-description">@Model.MerchantRecommendation.Description</p>
<p class="card-price">@Model.MerchantRecommendation.Price</p>
</div>
</article>
</div>
}
else
{
<h1>No Merchant recommendation!</h1>
}

<a class="button primary btnElement" href="./Product/@Model.MerchantRecommendation.Id">View product</a>
</article>
</div>

</div>
</div>
23 changes: 20 additions & 3 deletions FitFusion/FitFusionWeb/Pages/Recommendations.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RecommendationsModel : PageModel
[BindProperty]
public Product SystemRecommendation { get; set; } = new();
[BindProperty]
public Product MerchantRecommendation { get; set; } = new();
public Product? MerchantRecommendation { get; set; } = new();

public IActionResult OnGet()
{
Expand All @@ -31,7 +31,24 @@ public IActionResult OnGet()

CurrentUser = _userManager.GetUserByEmail(email);
SystemRecommendation = _orderManager.GetMostTrendingProduct(CurrentUser.Id);
MerchantRecommendation = _orderManager.GetMerchantRecommendation(CurrentUser.Id);

try
{
MerchantRecommendation = _orderManager.GetMerchantRecommendation(CurrentUser.Id);
}
catch
{
if(SystemRecommendation != null)
{
MerchantRecommendation = null;
return Page();
}
else
{
throw;
}
}

return Page();
}
}
Expand All @@ -41,7 +58,7 @@ public IActionResult OnGet()
}
catch (NullReferenceException)
{
return RedirectToPage("/Error", new { code = 404 });
return RedirectToPage("/Error", new { code = 414 });
}

return RedirectToPage("/Authentication/Login");
Expand Down
Binary file added FitFusionUML.pdf
Binary file not shown.
38 changes: 38 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Fit Fusion - Sport Nutrition Shop

![Fit Fusion Logo](https://www.creativefabrica.com/wp-content/uploads/2021/09/03/F-ff-logo-design-vector-Graphics-16738354-1-580x386.jpg)

Fit Fusion is a web and desktop application developed by Kaloyan Kulov for the individual assignment in Semester 2 of Software Engineering & ICT. This project aims to create a comprehensive solution for a sport nutrition shop, providing functionality for customers, staff, and the owner.

## Table of Contents
- [Introduction](#introduction)
- [User Roles and Credentials](#user-roles-and-credentials)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)

## Introduction

Fit Fusion is designed to be a versatile application catering to the needs of a sport nutrition shop. It includes features for customers to browse and purchase products, staff to manage inventory and orders, and an owner to oversee and manage the entire system.

## User Roles and Credentials

### Customer
- **Email:** [email protected]
- **Password:** [email protected]

### Staff
- **Email:** [email protected]
- **Password:** [email protected]

### Owner
- **Email:** [email protected]
- **Password:** [email protected]

## Installation

1. Clone the repository.
```bash
git clone https://github.com/KaloyankerR/Fit-Fusion.git

0 comments on commit 534777c

Please sign in to comment.