Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-wolf-ps committed Nov 19, 2019
1 parent 0e729a2 commit 3ec8d8a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 108 deletions.
1 change: 1 addition & 0 deletions BethanysPieShopHRM.Api/Models/ExpenseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Expense UpdateExpense(Expense expense)
foundExpense.Title = expense.Title;
foundExpense.Status = expense.Status;
foundExpense.Date = expense.Date;
foundExpense.ExpenseType = expense.ExpenseType;

_appDbContext.SaveChanges();

Expand Down
15 changes: 0 additions & 15 deletions BethanysPieShopHRM.Server/Components/StarRating.razor

This file was deleted.

123 changes: 57 additions & 66 deletions BethanysPieShopHRM.Server/Pages/ExpenseEdit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,65 @@
@using BethanysPieShopHRM.Shared
@inherits ExpenseEditBase

<div class="entity-edit">
<h1 class="page-title">Add New Expense</h1>
<div class="entity-edit">
<h1 class="page-title">Add New Expense</h1>
<div class="alert alert-info">@Message</div>
<EditForm Model="@Expense" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group row">
<label for="title" class="col-sm-3">Title: </label>
<InputText id="title" class="form-control col-sm-8" @bind-Value="@Expense.Title" placeholder="Enter title"></InputText>
</div>
<div class="form-group row">
<label for="Description" class="col-sm-3">Description: </label>
<InputTextArea id="Description" class="form-control col-sm-8" @bind-Value="@Expense.Description" placeholder="Enter Description"></InputTextArea>
</div>
<div class="form-group row">
<label for="Description" class="col-sm-3">Amount: </label>
<InputNumber id="Description" class="form-control col-sm-8" @bind-Value="@Expense.Amount" placeholder="Enter Description"></InputNumber>
</div>

@if (!Saved)
{
<EditForm Model="@Expense" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group row">
<label for="title" class="col-sm-3">Title: </label>
<InputText id="title" class="form-control col-sm-8" @bind-Value="@Expense.Title" placeholder="Enter title"></InputText>
</div>
<div class="form-group row">
<label for="Description" class="col-sm-3">Description: </label>
<InputTextArea id="Description" class="form-control col-sm-8" @bind-Value="@Expense.Description" placeholder="Enter Description"></InputTextArea>
</div>
<div class="form-group row">
<label for="Description" class="col-sm-3">Amount: </label>
<InputNumber id="Description" class="form-control col-sm-8" @bind-Value="@Expense.Amount" placeholder="Enter Description"></InputNumber>
</div>
<div class="form-group row">
<label for="expenseStats" class="col-sm-3">Expense Type: </label>
<InputSelect id="expenseStatus" class="form-control col-sm-8" @bind-Value=@Expense.ExpenseType>
<option value="@(ExpenseType.Training)">Training</option>
<option value="@(ExpenseType.Travel)">Travel</option>
<option value="@(ExpenseType.Conference)">Conference</option>
<option value="@(ExpenseType.Training)">Training</option>
<option value="@(ExpenseType.Office)">Office</option>
<option value="@(ExpenseType.Food)">Food</option>
<option value="@(ExpenseType.Transportation)">Transportation</option>
<option value="@(ExpenseType.Hotel)">Hotel</option>
<option value="@(ExpenseType.Other)">Other</option>
</InputSelect>
</div>

<div class="form-group row">
<label for="expenseStats" class="col-sm-3">Expense Type: </label>
<InputSelect id="expenseStatus" class="form-control col-sm-8" @bind-Value=@Expense.ExpenseType>
<option value="@(ExpenseType.Training)">Training</option>
<option value="@(ExpenseType.Travel)">Travel</option>
<option value="@(ExpenseType.Transportation)">Transportation</option>
<option value="@(ExpenseType.Food)">Food</option>
<option value="@(ExpenseType.Hotel)">Hotel</option>
<option value="@(ExpenseType.Office)">Office</option>
<option value="@(ExpenseType.Other)">Other</option>
</InputSelect>
</div>
<div class="form-group row">
<label for="date" class="col-sm-3">Date: </label>
<InputDate id="date" class="form-control col-sm-8" @bind-Value="@Expense.Date" placeholder="Enter date joined"></InputDate>
</div>

<div class="form-group row">
<label for="date" class="col-sm-3">Date: </label>
<InputDate id="date" class="form-control col-sm-8" @bind-Value="@Expense.Date" placeholder="Enter date joined"></InputDate>
</div>
<div class="form-group row">
<label for="employee" class="col-sm-3">Employee: </label>
<InputSelect id="employee" class="form-control col-sm-8" @bind-Value="@EmployeeId">
@foreach (var employee in Employees)
{
<option value="@employee.EmployeeId">@employee.FirstName</option>
}
</InputSelect>
</div>

<div class="form-group row">
<label for="employee" class="col-sm-3">Employee: </label>
<InputSelect id="employee" class="form-control col-sm-8" @bind-Value="@EmployeeId">
@foreach (var employee in Employees)
{
<option value="@employee.EmployeeId">@employee.FirstName</option>
}
/**/
</InputSelect>
</div>
<div class="form-group row">
<label for="currency" class="col-sm-3">Currency: </label>
<InputSelect id="currency" class="form-control col-sm-8" @bind-Value="@CurrencyId">
@foreach (var currency in Currencies)
{
<option value="@currency.CurrencyId">@currency.Name</option>
}
</InputSelect>
</div>

<div class="form-group row">
<label for="currency" class="col-sm-3">Currency: </label>
<InputSelect id="currency" class="form-control col-sm-8" @bind-Value="@CurrencyId">
@foreach (var currency in Currencies)
{
<option value="@currency.CurrencyId">@currency.Name</option>
}
/**/
</InputSelect>
</div>

<button type="submit" class="btn btn-primary edit-btn">Save Expense</button>
</EditForm>
}
else
{
<div class="alert alert-info">@Message</div>
<a class="btn btn-outline-primary" @onclick="@NavigateToOverview">Back to overview</a>

}
</div>
<button type="submit" class="btn btn-primary edit-btn">Save Expense</button>
</EditForm>
</div>
16 changes: 4 additions & 12 deletions BethanysPieShopHRM.Server/Pages/ExpenseEditBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@ public class ExpenseEditBase : ComponentBase

public Expense Expense { get; set; } = new Expense();

//needed to bind to select to value
//needed to bind to select value
protected string CurrencyId = "1";
protected string EmployeeId = "1";

[Parameter]
public string ExpenseId { get; set; }

public bool Saved = false;

public string Message { get; set; }

public List<Currency> Currencies { get; set; } = new List<Currency>();

public List<Employee> Employees { get; set; } = new List<Employee>();

protected override async Task OnInitializedAsync()
{
Saved = false;
Employees = (await EmployeeDataService.GetAllEmployees()).ToList();
Currencies = (await ExpenseService.GetAllCurrencies()).ToList();

Expand All @@ -51,7 +45,7 @@ protected override async Task OnInitializedAsync()
}
else
{
Expense = new Expense() { EmployeeId = 1, CurrencyId = 1, Status = ExpenseStatus.Open };
Expense = new Expense() { EmployeeId = 1, CurrencyId = 1, Status = ExpenseStatus.Open, ExpenseType = ExpenseType.Other };
}

CurrencyId = Expense.CurrencyId.ToString();
Expand Down Expand Up @@ -110,14 +104,12 @@ protected async Task HandleValidSubmit()
if (Expense.ExpenseId == 0) // New
{
await ExpenseService.AddExpense(Expense);
Message = "Saved!";
Saved = true;
NavigationManager.NavigateTo("/expenses");
}
else
{
await ExpenseService.UpdateExpense(Expense);
Message = "Saved!";
Saved = true;
NavigationManager.NavigateTo("/expenses");
}
}

Expand Down
11 changes: 4 additions & 7 deletions BethanysPieShopHRM.Server/Pages/TaskEdit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
<div class="form-group row">
<label for="title" class="col-sm-3">Title: </label>
<InputText id="title" class="form-control col-sm-8" @bind-Value="@Task.Title" placeholder="Enter title"></InputText>
<ValidationMessage class="offset-sm-3 col-sm-8" For="@(() => Task.Title)" />
</div>
<div class="form-group row">
<label for="Description" class="col-sm-3">Description: </label>
<InputTextArea id="Description" class="form-control col-sm-8" @bind-Value="@Task.Description" placeholder="Enter Description"></InputTextArea>
<ValidationMessage class="offset-sm-3 col-sm-8" For="@(() => Task.Description)" />
</div>

<div class="form-group row">
Expand All @@ -41,8 +39,6 @@
{
<option value="@employee.EmployeeId">@employee.FirstName</option>
}
/**/
/**/
</InputSelect>
</div>

Expand All @@ -61,7 +57,7 @@

public string Message { get; set; }

public int EmployeeId { get; set; }
protected string EmployeeId = "1";

[Inject]
private ITaskDataService taskService { get; set; }
Expand All @@ -82,16 +78,17 @@

protected async Task HandleValidSubmit()
{
Task.AssignedTo = int.Parse(EmployeeId);
var result = await taskService.AddTask(Task);

if (result != null)
{
navManager.NavigateTo("Index");
navManager.NavigateTo("/");
}
else
{
Message = "An error has occured";
}
}
}
</div>
</div>
16 changes: 8 additions & 8 deletions BethanysPieShopHRM.Shared/ExpenseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace BethanysPieShopHRM.Shared
{
public enum ExpenseType
{
Travel,
Conference,
Training,
Office,
Food,
Transportation,
Hotel,
Other
Travel = 1,
Conference = 2,
Training = 3,
Office = 4,
Food = 5,
Transportation = 6,
Hotel = 7,
Other = 8
}
}

0 comments on commit 3ec8d8a

Please sign in to comment.