Giter VIP home page Giter VIP logo

hhpwsbe's Introduction

HHPWsBe

hhpwsbe's People

Contributors

keanacobarde avatar

Watchers

 avatar

hhpwsbe's Issues

POST ORDERITEMS

User Story

I, as a cashier, should be able to add items to a user's order.

Acceptance Criteria

Endpoint URL: "order/additem"
As outlined by MVP requirements:

- **Add Order Items**: Staff can add items to orders from a menu that is viewable but not modifiable. Each "order item" represents a selection of a menu item for a particular order.

Dependencies

  • All setup tickets will need to be completed before work on this ticket could be done.

Dev Notes

  • Ideally, a DTO is created which encompasses the selection of an Order and an Item to add to that order.
    As seen in Bangazon - orderProduct DTO
namespace Bangazon.DTOs
{
    public class addProductDTO
    {
        public int OrderId { get; set; }
        public int ProductId { get; set; }
    }
}
  • API Call
            //ADDING PRODUCTS
            app.MapPost("/orders/addProduct", (BangazonDbContext db, addProductDTO newProduct) =>
            {
                var order = db.Orders.Include(o => o.Products).FirstOrDefault(o => o.Id == newProduct.OrderId);

                if (order == null)
                {
                    return Results.NotFound("Order not found.");
                }

                var product = db.Products.Find(newProduct.ProductId);

                if (product == null)
                {
                    return Results.NotFound("Product not found.");
                }

                order.Products.Add(product);

                db.SaveChanges();

                return Results.Created($"/orders/addProduct", newProduct);
            });

DELETE ORDERITEMS

User Story

  • I, as a cashier, should be able to remove items from an order if I mistakenly add incorrect items.

Acceptance Criteria

  • Endpoint: "/order/removeitem"
    As laid out by MVP requirements:
Delete Order Items: Remove specific items from an order.

Dependencies

  • All setup tickets will need to be completed before work on this ticket could be done.

Dev Notes

  • Ideally, a DTO is created which encompasses the selection of an Order and an Item to add to that order.
    As seen in Bangazon - orderProduct DTO
namespace Bangazon.DTOs
{
    public class addProductDTO
    {
        public int OrderId { get; set; }
        public int ProductId { get; set; }
    }
}
  • API Call
  • YOU MAY UTILIZE THE DTO AS LONG AS IT IS A 'POST' CALL.
            //ADDING PRODUCTS
            app.MapPost("/orders/addProduct", (BangazonDbContext db, addProductDTO newProduct) =>
            {
                var order = db.Orders.Include(o => o.Products).FirstOrDefault(o => o.Id == newProduct.OrderId);

                if (order == null)
                {
                    return Results.NotFound("Order not found.");
                }

                var product = db.Products.Find(newProduct.ProductId);

                if (product == null)
                {
                    return Results.NotFound("Product not found.");
                }

                order.Products.Remove(product);

                db.SaveChanges();

                return Results.Created($"/orders/addProduct", newProduct);
            });

SETUP - ERD + EF and PostgreSQL Setup

User Story

  • I, as the developer, will need to install the required dependencies to manipulate and call upon Entity Framework as well as PostgreSQL functionality.

Acceptance Criteria

  • Upon cloning of repo, the Entity Framework Core as well as the PostgreSQL extension should be installed.
  • Program.cs will need to be modified.
  • The following ERD will need to take into account the requested MVP functionality:
User Authentication: Staff will log in securely using Firebase Authentication, ensuring a reliable and secure access system.

Home Screen Display: After logging in, staff will be greeted with a user-friendly interface offering options to view and create orders, and check revenue.

Comprehensive Order Management:

View All Orders: Staff can access a detailed list of all orders.
Order Details and Associated Items: Ability to view specific details and items for each order.
Create and Update Orders: Functionality to add new orders and modify existing ones, including customer details and order type.
Delete Orders and Order Items: Options to remove orders or specific items from the system.
Order Item Management:

Add Order Items: Staff can add items to orders from a menu that is viewable but not modifiable. Each "order item" represents a selection of a menu item for a particular order.
Delete Order Items: Remove specific items from an order.
Closing and Revenue Tracking:

Close Order with Restrictions: Feature to finalize orders with payment type and tip amount, changing order status from "Open" to "Closed".
Revenue Node Addition: Automatic creation of a record capturing essential financial details upon order closure.
View Total Revenue: Ability to view the cumulative revenue generated.

Dependencies

  • These extensions can be installed and implemented before or after test data is seeded. The ERD will need to be created as soon as MVP requirements are understood.

Dev Notes

  • Required Commands
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 6.0

dotnet add package Microsoft.EntityFrameworkCore.Design --version 6.0

dotnet user-secrets init

dotnet user-secrets set "<Name>DbConnectionString" "Host=localhost;Port=5432;Username=postgres;Password=<your_postgresql_password>;Database=CreekRiver"
  • Program.cs Modifications:
using Microsoft.EntityFrameworkCore;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http.Json;

// ADDED ABOVE var app = builder.Build() 
// allows passing datetimes without time zone data 
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);

// allows our api endpoints to access the database through Entity Framework Core
builder.Services.AddNpgsql<CreekRiverDbContext>(builder.Configuration["CreekRiverDbConnectionString"]);

// Set the JSON serializer options
builder.Services.Configure<JsonOptions>(options =>
{
    options.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
});

builder.Services.AddCors(options =>
{
    options.AddDefaultPolicy(policy =>
    {
        policy.WithOrigins("http://localhost:3000")
            .AllowAnyOrigin()
            .AllowAnyMethod()
            .AllowAnyHeader();
    });
});

//ADDED AFTER BUILD
app.UseCors();

GET USERS

User Story

I, as the cashier, will need to log in to utilize the application.

Acceptance Criteria

  • Endpoint URL: "/checkuser"
  • As laid out by MVP requirements:
User Authentication: Staff will log in securely using Firebase Authentication, ensuring a reliable and secure access system.

Dependecies

  • All setup tickets will need to be completed before work on this ticket could be done.

Dev Notes

  • A blend between the frontend and the backend; however, it's a process heavily focused on the frontend with useAuth().

  • Backend API Call, as utilized in Rare

            app.MapPost("/api/checkuser", (RareDbContext db, UserAuthDto userAuthDto) =>
            {
                var userUid = db.Users.SingleOrDefault(user => user.Uid == userAuthDto.Uid);

                if (userUid == null)
                {
                    return Results.NotFound();
                }
                else
                {
                    return Results.Ok(userUid);
                }
            });

DELETE ITEMS

User Story

I, as a cashier/staff member, should be able to delete items from the system.

Acceptance Criteria

  • Endpoint: "/items/{itemId}"
  • As outlined by MVP requirements:
Delete Orders and Order Items: Options to remove orders or specific items from the system.

Dependencies

  • All setup issues must be completed before work can be started on this ticket. Test data needs to be seeded to test the full functionality of this API call.

Dev Notes

CreekRiver Delete - Reservations

app.MapDelete("/api/reservations/{id}", (CreekRiverDbContext db, int id) =>
{
    Reservation reservations = db.Reservations.SingleOrDefault(campsite => campsite.Id == id);
    if (reservations == null)
    {
        return Results.NotFound();
    }
    db.Reservations.Remove(reservations);
    db.SaveChanges();
    return Results.NoContent();

});

GET ORDERS + GET ORDER BY ID

User Story

  • As a user who is serving as the cashier, I would like to see all the orders as well as their associated items.

Acceptance Criteria

  • Endpoint URL: "/orders"
  • As highlighted by the ticket descriptions:
View All Orders
Given: An authenticated cashier.
When: They choose to view all orders.
Then: They should see a list of all orders with relevant details.

Get Order by ID
Order Details and Associated Items: Ability to view specific details and items for each order.

Dependecies

All setup issues need to be completed before this endpoint is built. Test data will need to be seeded, and class structure needs to exist.

Dev Notes

Typical 'GET' endpoints appear as follows:
NOTE: .Include() will need to be added to take into account items.
GET - CREEKRIVER

app.MapGet("/api/campsites", (CreekRiverDbContext db) =>
{
    return db.Campsites.ToList();
});

GET - BY USER ID, RARE - W/O ENTITY FRAMEWORK

app.MapGet("/users/{id}", (int id) => {
    Users user = users.FirstOrDefault(u => u.Id == id);
    if (user == null)
    {
        return Results.NotFound();
    }
    return Results.Ok(user);
});

UPDATE ORDERS

User Story

Acceptance Criteria

  • Endpoint URL: "/orders/{orderId}"
    As pulled from acceptance criteria highlighted by MVP:
Create and Update Orders: Functionality to add new orders and modify existing ones, including customer details and order type.

NOTE: This does not include the editing of the items within an order, only the order details. Adding and deleting of items from an order will be outlined in a separate issue ticket categorized as 'order items'.

Dependecies

  • All setup tickets will need to be completed before work on this issue is started.

Dev Notes

CreekRiver - Campsites

app.MapPut("/api/campsites/{id}", (CreekRiverDbContext db, int id, Campsite campsite) =>
{
    Campsite campsiteToUpdate = db.Campsites.SingleOrDefault(campsite => campsite.Id == id);
    if (campsiteToUpdate == null)
    {
        return Results.NotFound();
    }
    campsiteToUpdate.Nickname = campsite.Nickname;
    campsiteToUpdate.CampsiteTypeId = campsite.CampsiteTypeId;
    campsiteToUpdate.ImageUrl = campsite.ImageUrl;

    db.SaveChanges();
    return Results.NoContent();
});

DELETE ORDERS

User Story

I, as a cashier who is utilizing this POS, should be able to delete orders that are either cancelled or created by mistake.

Acceptance Criteria

  • Endpoint: "/orders/{orderId}"
    As outlined by acceptance criteria highlighted by MVP:
Delete Orders and Order Items: Options to remove orders or specific items from the system.

Dependencies

  • All setup tickets must be done before work can be completed with this endpoint, and test data will also need to be seeded to test functionality.

Dev Notes

CreekRiver Delete - Reservations

app.MapDelete("/api/reservations/{id}", (CreekRiverDbContext db, int id) =>
{
    Reservation reservations = db.Reservations.SingleOrDefault(campsite => campsite.Id == id);
    if (reservations == null)
    {
        return Results.NotFound();
    }
    db.Reservations.Remove(reservations);
    db.SaveChanges();
    return Results.NoContent();

});

SETUP - CLASSES + SEEDING TEST DATA

User Story

I, as the developer, must create classes to represent the entities outlined within the ERD to all for Entity Framework to import said entities to PostgreSQL database.

Acceptance Criteria

  • Listed classes should follow the structure and data type of the entities within the provided ERD
  • All tables outside of join tables should refer to their respective classes
  • The following entities will have a related class file:
  • Users
  • Order
  • Items
  • Test data will need to be created to match the ERD.

ICOllections/Lists will need to be referenced between the following entities

  • Items and Orders

Dependencies

  • N / A, this is one of the first tasks which need to be completed, even before the seeding of test data.

Dev Notes

  • Class Structure, Models > Orders and Items
  • Will create the join table between Order and Items
using System.ComponentModel.DataAnnotations;

namespace Bangazon.Models
{
    public class Product
    {
        public int Id { get; set; }
        [Required]
        public string Title { get; set; }
        public string Description { get; set; }
        public string ImageUrl { get; set; }
        public int QuantityAvailable { get; set; }
        public float Price { get; set; }
        public int SellerId { get; set; }
        public int CategoryId { get; set; }
        public ICollection<Order> Orders { get; set; }
    }
}

Examples of utilizing accumulators to generate 'Totals' - CreekRiver:

    public decimal? TotalCost
    {
        get
        {
            if (Campsite?.CampsiteType != null)
            {
                return Campsite.CampsiteType.FeePerNight * TotalNights + _reservationBaseFee;
            }
            return null;
        }
    }
  • Initial Migration:
dotnet ef migrations add InitialCreate
dotnet ef database update

GET ITEMS

User Story

I, as a cashier, will need to read all items before I am able to add them to my cart.

Acceptance Criteria

  • Endpoint URL: "/items"
    As outlined in MVP requirements:
Staff can add items to orders from a menu that is viewable but not modifiable.

NOTE: While MVP did not explicitly outline the need for this API call, it can be inferred that the core functionality of adding and removing items to an order REQUIRES a user to read the items first.

Dependencies

  • All setup tickets will need to be completed before work on this can commence. Test data will need to be seeded to test the full functionality of this API call.

Dev Notes

Typical 'GET' endpoints appear as follows:
GET - CREEKRIVER

app.MapGet("/api/campsites", (CreekRiverDbContext db) =>
{
    return db.Campsites.ToList();
});

CREATE ORDERS

User Story

I, as a user who is utilizing the POS as a cashier, should be able to create all the new orders a customer is requesting.

Acceptance Criteria

  • Endpoint URL: "/orders/new"
  • As outlined by MVP requirements:
2. **Comprehensive Order Management**:
    - **View All Orders**: Staff can access a detailed list of all orders.
    - **Order Details and Associated Items**: Ability to view specific details and items for each order.
    - **Create and Update Orders**: Functionality to add new orders and modify existing ones, including customer details and order type.
    - **Delete Orders and Order Items**: Options to remove orders or specific items from the system.

Dependencies

  • This issue ticket is dependent on the completion of all setup tickets. Test data isn't required for the testing of this call, however.

Dev Notes

Creek River (Post) - Reservations

app.MapPost("/api/reservations", (CreekRiverDbContext db, Reservation newRes) =>
{
    try
    {
        db.Reservations.Add(newRes);
        db.SaveChanges();
        return Results.Created($"/api/reservations/{newRes.Id}", newRes);
    }
    catch (DbUpdateException)
    {
        return Results.BadRequest("Invalid data submitted");
    }
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.