Click here to Skip to main content
15,357,966 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I would like to ask a question on an old subject such as the MusicStore at this address: https://github.com/dnkato/MvcMusicStore-Tutorial/tree/master/MvcMusicStore
In the Models folder there is a file (ShoppingCart.cs) :

Quote:
Before
:

C#
using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.Mvc;
	

	namespace MvcMusicStore.Models
	{
	    public partial class ShoppingCart
	    {
	        MusicStoreEntities storeDB = new MusicStoreEntities();
	        string ShoppingCartId { get; set; }
	        public const string CartSessionKey = "CartId";
	        public static ShoppingCart GetCart(HttpContextBase context)
	        {
	            var cart = new ShoppingCart();
	            cart.ShoppingCartId = cart.GetCartId(context);
	            return cart;
	        }
	        // Helper method to simplify shopping cart calls
	        public static ShoppingCart GetCart(Controller controller)
	        {
	            return GetCart(controller.HttpContext);
	        }
	        public void AddToCart(Album album)
	        {
	            // Get the matching cart and album instances
	            var cartItem = storeDB.Carts.SingleOrDefault(
	                c => c.CartId == ShoppingCartId
	                && c.AlbumId == album.AlbumId);
	

	            if (cartItem == null)
	            {
	                // Create a new cart item if no cart item exists
	                cartItem = new Cart
	                {
	                    AlbumId = album.AlbumId,
	                    CartId = ShoppingCartId,
	                    Count = 1,
	                    DateCreated = DateTime.Now
	                };
	                storeDB.Carts.Add(cartItem);
	            }
	            else
	            {
	                // If the item does exist in the cart, 
	                // then add one to the quantity
	                cartItem.Count++;
	            }
	            // Save changes
	            storeDB.SaveChanges();
	        }
	        public int RemoveFromCart(int id)
	        {
	            // Get the cart
	            var cartItem = storeDB.Carts.Single(
	                cart => cart.CartId == ShoppingCartId
	                && cart.RecordId == id);
	

	            int itemCount = 0;
	

	            if (cartItem != null)
	            {
	                if (cartItem.Count > 1)
	                {
	                    cartItem.Count--;
	                    itemCount = cartItem.Count;
	                }
	                else
	                {
	                    storeDB.Carts.Remove(cartItem);
	                }
	                // Save changes
	                storeDB.SaveChanges();
	            }
	            return itemCount;
	        }
	        public void EmptyCart()
	        {
	            var cartItems = storeDB.Carts.Where(
	                cart => cart.CartId == ShoppingCartId);
	

	            foreach (var cartItem in cartItems)
	            {
	                storeDB.Carts.Remove(cartItem);
	            }
	            // Save changes
	            storeDB.SaveChanges();
	        }
	        public List<Cart> GetCartItems()
	        {
	            return storeDB.Carts.Where(
	                cart => cart.CartId == ShoppingCartId).ToList();
	        }
	        public int GetCount()
	        {
	            // Get the count of each item in the cart and sum them up
	            int? count = (from cartItems in storeDB.Carts
	                          where cartItems.CartId == ShoppingCartId
	                          select (int?)cartItems.Count).Sum();
	            // Return 0 if all entries are null
	            return count ?? 0;
	        }
	        public decimal GetTotal()
	        {
	            // Multiply album price by count of that album to get 
	            // the current price for each of those albums in the cart
	            // sum all album price totals to get the cart total
	            decimal? total = (from cartItems in storeDB.Carts
	                              where cartItems.CartId == ShoppingCartId
	                              select (int?)cartItems.Count *
	                              cartItems.Album.Price).Sum();
	

	            return total ?? decimal.Zero;
	        }
	        public int CreateOrder(Order order)
	        {
	            decimal orderTotal = 0;
	

	            var cartItems = GetCartItems();
	            // Iterate over the items in the cart, 
	            // adding the order details for each
	            foreach (var item in cartItems)
	            {
	                var orderDetail = new OrderDetail
	                {
	                    AlbumId = item.AlbumId,
	                    OrderId = order.OrderId,
	                    UnitPrice = item.Album.Price,
	                    Quantity = item.Count
	                };
	                // Set the order total of the shopping cart
	                orderTotal += (item.Count * item.Album.Price);
	

	                storeDB.OrderDetails.Add(orderDetail);
	

	            }
	            // Set the order's total to the orderTotal count
	            order.Total = orderTotal;
	

	            // Save the order
	            storeDB.SaveChanges();
	            // Empty the shopping cart
	            EmptyCart();
	            // Return the OrderId as the confirmation number
	            return order.OrderId;
	        }
	        // We're using HttpContextBase to allow access to cookies.
	        public string GetCartId(HttpContextBase context)
	        {
	            if (context.Session[CartSessionKey] == null)
	            {
	                if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
	                {
	                    context.Session[CartSessionKey] =
	                        context.User.Identity.Name;
	                }
	                else
	                {
	                    // Generate a new random GUID using System.Guid class
	                    Guid tempCartId = Guid.NewGuid();
	                    // Send tempCartId back to client as a cookie
	                    context.Session[CartSessionKey] = tempCartId.ToString();
	                }
	            }
	            return context.Session[CartSessionKey].ToString();
	        }
	        // When a user has logged in, migrate their shopping cart to
	        // be associated with their username
	        public void MigrateCart(string userName)
	        {
	            var shoppingCart = storeDB.Carts.Where(
	                c => c.CartId == ShoppingCartId);
	

	            foreach (Cart item in shoppingCart)
	            {
	                item.CartId = userName;
	            }
	            storeDB.SaveChanges();
	        }
	    }
	}


Quote:
After
:

C#
using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.Mvc;
	

	namespace MvcMusicStore.Models
	{
	    public partial class ShoppingCart
	    {
	        MusicStoreEntities storeDB = new MusicStoreEntities();

	        string ShoppingCartId { get; set; }

 public double ReturInput { get; set; }

	        public const string CartSessionKey = "CartId";
	        public static ShoppingCart GetCart(HttpContextBase context)
	        {
	            var cart = new ShoppingCart();
	            cart.ShoppingCartId = cart.GetCartId(context);
	            return cart;
	        }
	        // Helper method to simplify shopping cart calls
	        public static ShoppingCart GetCart(Controller controller)
	        {
	            return GetCart(controller.HttpContext);
	        }
	        public void AddToCart(Album album)
	        {
	            // Get the matching cart and album instances
	            var cartItem = storeDB.Carts.SingleOrDefault(
	                c => c.CartId == ShoppingCartId
	                && c.AlbumId == album.AlbumId);
	

	            if (cartItem == null)
	            {
	                // Create a new cart item if no cart item exists
	                cartItem = new Cart
	                {
	                    AlbumId = album.AlbumId,
	                    CartId = ShoppingCartId,
	                    Count = 1,
	                    DateCreated = DateTime.Now
	                };
	                storeDB.Carts.Add(cartItem);
	            }
	            else
	            {
	                // If the item does exist in the cart, 
	                // then add one to the quantity
	                cartItem.Count++;
	            }
	            // Save changes
	            storeDB.SaveChanges();
	        }
	        public int RemoveFromCart(int id)
	        {
	            // Get the cart
	            var cartItem = storeDB.Carts.Single(
	                cart => cart.CartId == ShoppingCartId
	                && cart.RecordId == id);
	

	            int itemCount = 0;
	

	            if (cartItem != null)
	            {
	                if (cartItem.Count > 1)
	                {
	                    cartItem.Count--;
	                    itemCount = cartItem.Count;
	                }
	                else
	                {
	                    storeDB.Carts.Remove(cartItem);
	                }
	                // Save changes
	                storeDB.SaveChanges();
	            }
	            return itemCount;
	        }
	        public void EmptyCart()
	        {
	            var cartItems = storeDB.Carts.Where(
	                cart => cart.CartId == ShoppingCartId);
	

	            foreach (var cartItem in cartItems)
	            {
	                storeDB.Carts.Remove(cartItem);
	            }
	            // Save changes
	            storeDB.SaveChanges();
	        }
	        public List<Cart> GetCartItems()
	        {
	            return storeDB.Carts.Where(
	                cart => cart.CartId == ShoppingCartId).ToList();
	        }
	        public int GetCount()
	        {
 
	            // Get the count of each item in the cart and sum them up
	            int? count = (from cartItems in storeDB.Carts
	                          where cartItems.CartId == ShoppingCartId
	                          select (int?)cartItems.Count).Sum();
	            // Return 0 if all entries are null
	            return count ?? 0;
	        }
	        public decimal GetTotal()
	        {



	ReturInput = 7.50;

decimal ? total = (decimal?)(from cartItems in storeDB.Carts where cartItems.CartId == ShoppingCartId select (int?)cartItems.Count * ReturInput).Sum();


	            return total ?? decimal.Zero;
	        }
	        public int CreateOrder(Order order)
	        {
	            decimal orderTotal = 0;
	

	            var cartItems = GetCartItems();
	            // Iterate over the items in the cart, 
	            // adding the order details for each
	            foreach (var item in cartItems)
	            {
	                var orderDetail = new OrderDetail
	                {
	                    AlbumId = item.AlbumId,
	                    OrderId = order.OrderId,
	                    UnitPrice = item.Album.Price,
	                    Quantity = item.Count
	                };

	  orderTotal = (decimal)(item.Count * ReturInput);
	             storeDB.OrderDetails.Add(orderDetail);


	orderTotal = (decimal)(item.Count * RetourInput);
	                storeDB.OrderDetails.Add(orderDetail);
	

	            }
	            // Set the order's total to the orderTotal count
	            order.Total = orderTotal;
	

	            // Save the order
	            storeDB.SaveChanges();
	            // Empty the shopping cart
	            EmptyCart();
	            // Return the OrderId as the confirmation number
	            return order.OrderId;
	        }
	        // We're using HttpContextBase to allow access to cookies.
	        public string GetCartId(HttpContextBase context)
	        {
	            if (context.Session[CartSessionKey] == null)
	            {
	                if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
	                {
	                    context.Session[CartSessionKey] =
	                        context.User.Identity.Name;
	                }
	                else
	                {
	                    // Generate a new random GUID using System.Guid class
	                    Guid tempCartId = Guid.NewGuid();
	                    // Send tempCartId back to client as a cookie
	                    context.Session[CartSessionKey] = tempCartId.ToString();
	                }
	            }
	            return context.Session[CartSessionKey].ToString();
	        }
	        // When a user has logged in, migrate their shopping cart to
	        // be associated with their username
	        public void MigrateCart(string userName)
	        {
	            var shoppingCart = storeDB.Carts.Where(
	                c => c.CartId == ShoppingCartId);
	

	            foreach (Cart item in shoppingCart)
	            {
	                item.CartId = userName;
	            }
	            storeDB.SaveChanges();
	        }
	    }
	}


It works well with the price of 7.50
Is it possible to replace 7.50 with an input text from the view Details.cshtml ?
In what way ?

What I have tried:

Quote:
HttpContext.Current.Session["Name"] =Request.Form["textbox1"];
Posted
Updated 15-Mar-22 22:00pm

It's possible to do, but in this scenario, you should not be accepting a price value from the View because a user could enter Zero, and the Total would be Zero i.e. FREE goods!

Instead, set the price in the table where the Item is being queried from. e.g. column name: ItemPrice.

Then in code, replace the 7.50 variable with the price of that item instead.
   
Comments
LSB71 16-Mar-22 3:59am
   
This is what I tried to do with my tables but without success... That's why sending a price once established would be easier...
See below :
njammy 22-Mar-22 18:33pm
   
Please share details of what you "tried to do with your tables" but without success and I'll try and help
Richard Deeming 16-Mar-22 4:49am
   
That's in the optimistic case. Many users would enter a negative price, and get you to pay them to take your goods. :)

Hello,
Thank you very much for dwelling on my project, yes indeed I have already done this procedure but I am a photographer and I am trying to create a sales site for my photographs.
But in my case the same photo could have several different prices depending on its size and the type of printing.
Unfortunately I do not know how to build the necessary tables according to these criteria that my client can do.
I built my page a bit like this :(Example)
The final price would be displayed on the screen, in a tag (p)
HTML
<p id="ReturnPrice" class="card-text p-3 mb-2 bg-secondary text-white">
                        Here will be displayed the Price
</p>

It is very easy for me to recover the sum even in hidden session or sessionstorage style with jquery without taking the value that is displayed on the screen.
I tried to add 3 tables like this but it doesn't work, I don't have experience... here it is :

SQL
[dbo].[Gammes] = ranges (type of print)
[dbo].[Tailles] = sizes (four different sizes)
[dbo].[TableTarifs] = price table (combined the different prices)


SQL
create database Bdd_Album_Photos;

use Bdd_Album_Photos; 

CREATE TABLE [dbo].[__MigrationHistory] (
    [MigrationId]    NVARCHAR (150)  NOT NULL,
    [ContextKey]     NVARCHAR (300)  NOT NULL,
    [Model]          VARBINARY (MAX) NOT NULL,
    [ProductVersion] NVARCHAR (32)   NOT NULL,
    CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY CLUSTERED ([MigrationId] ASC, [ContextKey] ASC)
);
CREATE TABLE [dbo].[Albums] (
    [AlbumId]      INT             IDENTITY (1, 1) NOT NULL,
    [CategorieId]  INT             NOT NULL,
    [PhotoId]      INT             NOT NULL,
    [TableTarifId]      INT        NULL,
    [Title]        NVARCHAR (MAX)  NULL,
    [Prix]         DECIMAL (18, 2) NOT NULL,
    [UrlMiniature] NVARCHAR (1024) CONSTRAINT [UrlMiniature] DEFAULT (N'/Content/Images/placeholder.gif') NULL
);

CREATE TABLE [dbo].[Carts] (
    [RecordId]    INT            IDENTITY (1, 1) NOT NULL,
    [CartId]      NVARCHAR (MAX) NULL,
    [AlbumId]     INT            NOT NULL,
    [Count]       INT            NOT NULL,
    [DateCreated] DATETIME       NOT NULL
);
CREATE TABLE [dbo].[Categories] (
    [CategorieId] INT            IDENTITY (1, 1) NOT NULL,
    [Name]        NVARCHAR (MAX) NULL,
    [Description] NVARCHAR (MAX) NULL
);
CREATE TABLE [dbo].[OrderDetails] (
    [OrderDetailId] INT             IDENTITY (1, 1) NOT NULL,
    [OrderId]       INT             NOT NULL,
    [AlbumId]       INT             NOT NULL,
    [Quantity]      INT             NOT NULL,
    [UnitPrice]     DECIMAL (18, 2) NOT NULL
);
CREATE TABLE [dbo].[Orders] (
    [OrderId]    INT             IDENTITY (1, 1) NOT NULL,
    [OrderDate]  DATETIME        NOT NULL,
    [Username]   NVARCHAR (MAX)  NULL,
    [FirstName]  NVARCHAR (160)  NOT NULL,
    [LastName]   NVARCHAR (160)  NOT NULL,
    [Address]    NVARCHAR (70)   NOT NULL,
    [City]       NVARCHAR (40)   NOT NULL,
    [State]      NVARCHAR (40)   NOT NULL,
    [PostalCode] NVARCHAR (10)   NOT NULL,
    [Country]    NVARCHAR (40)   NOT NULL,
    [Phone]      NVARCHAR (24)   NOT NULL,
    [Email]      NVARCHAR (MAX)  NOT NULL,
    [Total]      DECIMAL (18, 2) NOT NULL
);
CREATE TABLE [dbo].[Photos] (
    [PhotoId] INT            IDENTITY (1, 1) NOT NULL,
    [Name]    NVARCHAR (MAX) NULL
);

CREATE TABLE [dbo].[Gammes] (
    [GammeId] INT IDENTITY (1, 1) NOT NULL,
    [Name] NVARCHAR (MAX)  NOT NULL,
);

CREATE TABLE [dbo].[Tailles] (
    [TailleId] INT IDENTITY (1, 1) NOT NULL,
    [Name]  NVARCHAR (10)  NOT NULL
);

CREATE TABLE [dbo].[TableTarifs] (
    [TableTarifId] INT IDENTITY (1, 1) NOT NULL,
	[GammeId]       INT             NOT NULL,
    [TailleId]       INT             NOT NULL,
    [PrixUnit]  DECIMAL (10, 2) NOT NULL
);

alter table [dbo].[Gammes] add constraint [Pk_Gamme] primary key CLUSTERED ([GammeId] ASC);
alter table [dbo].[Tailles] add constraint [Pk_Taille] primary key CLUSTERED ([TailleId] ASC);
alter table [dbo].[TableTarifs] add constraint [Pk_TableTarif] primary key CLUSTERED ([TableTarifId] ASC);
alter table [dbo].[Albums] add constraint [Pk_Album] primary key CLUSTERED ([AlbumId] ASC);
alter table [dbo].[Carts] add constraint [Pk_Cart] primary key ([RecordId] ASC);
alter table [dbo].[Categories] add constraint [Pk_Categorie] primary key CLUSTERED ([CategorieId] ASC);
alter table [dbo].[Orders] add constraint [Pk_Order] primary key CLUSTERED ([OrderId] ASC);
alter table [dbo].[OrderDetails] add constraint [Pk_OrderDetail] primary key CLUSTERED ([OrderDetailId] ASC);
alter table [dbo].[Photos] add constraint [Pk_Photo] primary key CLUSTERED ([PhotoId] ASC);

alter table [dbo].[Albums] add constraint Fk_AlbumTableTarif foreign key ([TableTarifId]) references [dbo].[TableTarifs]([TableTarifId]);
alter table [dbo].[TableTarifs] add constraint Fk_TableTarifGamme foreign key ([GammeId]) references [dbo].[Gammes]([GammeId]) ON DELETE CASCADE;
alter table [dbo].[TableTarifs] add constraint Fk_TableTarifTaille foreign key ([TailleId]) references [dbo].[Tailles]([TailleId]) ON DELETE CASCADE;
alter table [dbo].[Albums] add constraint Fk_AlbumCategorie foreign key ([CategorieId]) references [dbo].[Categories]([CategorieId]) ON DELETE CASCADE;
alter table [dbo].[Albums] add constraint Fk_AlbumPhoto foreign key ([PhotoId]) references [dbo].[Photos]([PhotoId]) ON DELETE CASCADE;
alter table [dbo].[OrderDetails] add constraint Fk_OrderDetailAlbum foreign key ([AlbumId]) references [dbo].[Albums]([AlbumId]) ON DELETE CASCADE;
alter table [dbo].[OrderDetails] add constraint Fk_OrderDetailOrder foreign key ([OrderId]) references [dbo].[Orders]([OrderId]) ON DELETE CASCADE;
alter table [dbo].[Carts] add constraint Fk_CartAlbum foreign key ([AlbumId]) references [dbo].[Albums]([AlbumId]) ON DELETE CASCADE;

SET IDENTITY_INSERT [dbo].[Gammes] ON
INSERT [dbo].[Gammes] ([GammeId], [Name]) VALUES (1, N'Mat')
INSERT [dbo].[Gammes] ([GammeId], [Name]) VALUES (2, N'Brillant')
INSERT [dbo].[Gammes] ([GammeId], [Name]) VALUES (3, N'PhotoRicePaper')
INSERT [dbo].[Gammes] ([GammeId], [Name]) VALUES (4, N'FineArtClassique')
INSERT [dbo].[Gammes] ([GammeId], [Name]) VALUES (5, N'FineArtPrestige')
SET IDENTITY_INSERT [dbo].[Gammes] OFF

SET IDENTITY_INSERT [dbo].[Tailles] ON
INSERT [dbo].[Tailles] ([TailleId], [Name]) VALUES (1, N'20x30')
INSERT [dbo].[Tailles] ([TailleId], [Name]) VALUES (2, N'30x40')
INSERT [dbo].[Tailles] ([TailleId], [Name]) VALUES (3, N'40x50')
INSERT [dbo].[Tailles] ([TailleId], [Name]) VALUES (4, N'50x70')
SET IDENTITY_INSERT [dbo].[Tailles] OFF

SET IDENTITY_INSERT [dbo].[TableTarifs] ON
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (1, 1, 1, CAST(25.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (2, 1, 2, CAST(30.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (3, 1, 3, CAST(35.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (4, 1, 4, CAST(40.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (5, 2, 1, CAST(30.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (6, 2, 2, CAST(35.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (7, 2, 3, CAST(40.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (8, 2, 4, CAST(45.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (9, 3, 1, CAST(35.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (10, 3, 2, CAST(40.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (11, 3, 3, CAST(45.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (12, 3, 4, CAST(50.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (13, 4, 1, CAST(40.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (14, 4, 2, CAST(45.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (15, 4, 3, CAST(55.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (16, 4, 4, CAST(65.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (17, 5, 1, CAST(45.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (18, 5, 2, CAST(55.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (19, 5, 3, CAST(65.00 AS Numeric(10, 2)))
INSERT [dbo].[TableTarifs] ([TableTarifId], [GammeId], [TailleId], [PrixUnit]) VALUES (20, 5, 4, CAST(80.00 AS Numeric(10, 2)))
SET IDENTITY_INSERT [dbo].[TableTarifs] OFF

SET IDENTITY_INSERT [dbo].[Categories] ON
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (1, N'Animaux', N'Description sur les Animaux.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (2, N'Humain', N'Description sur les Humain.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (3, N'Mécanique', N'Description sur les Mécanique.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (4, N'Nature', N'Description sur les Nature.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (5, N'Oiseaux', N'Description sur les Oiseaux.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (6, N'Paysage', N'Description sur les Paysage.')
INSERT [dbo].[Categories] ([CategorieId], [Name], [Description]) VALUES (7, N'Création', N'Description sur les Création.')
SET IDENTITY_INSERT [dbo].[Categories] OFF

SET IDENTITY_INSERT [dbo].[Photos] ON
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (1, N'PB161252')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (2, N'PB181614')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (3, N'PC021603')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (4, N'PC032156')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (5, N'PC021504')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (6, N'PC052829')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (7, N'PC021509')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (8, N'PC073087')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (9, N'PC073147')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (10, N'PC073132')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (11, N'PC073161')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (12, N'PC052777')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (13, N'PC042304')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (14, N'PC021645')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (15, N'PB301087')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (16, N'PB191730')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (17, N'PC083415')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (18, N'PB181618')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (19, N'PB181688')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (20, N'PB140979')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (21, N'PB080213')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (22, N'PB140964')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (23, N'PB140985')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (24, N'PB100387')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (25, N'PB100390')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (26, N'PB120656')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (27, N'PB120661')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (28, N'PB120668')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (29, N'PC052903')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (30, N'PC062980')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (31, N'PC083325')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (32, N'PB270714')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (33, N'PB260677')
INSERT [dbo].[Photos] ([PhotoId], [Name]) VALUES (34, N'PB270736')
SET IDENTITY_INSERT [dbo].[Photos] OFF

SET IDENTITY_INSERT [dbo].[Albums] ON
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (1, 6, 29, N'Beauté des couleurs sur la rivière Okavango, Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (2, 6, 30, N'Coucher de soleil sur la rivière Chobe, Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (3, 6, 31, N'Chutes Victoria sur le fleuve Zambèze, frontière naturelle Zimbabwe et Zambie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (4, 6, 32, N'Sossusvlei désert du namib, Namibie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (5, 6, 33, N'Désert du namib, Namibie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (6, 6, 34, N'Désert du namib, Namibie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (7, 5, 26, N'Aras de Macao Sur la côte pacifique du Costa Rica, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (8, 5, 27, N'Aras de Macao Sur la côte pacifique du Costa Rica, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (9, 5, 28, N'Toucan à carène, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (10, 4, 18, N'Le maïs, sept mille ans d histoire.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (11, 4, 19, N'Marché de San Cristóbal de Las Casas, Méxique.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (12, 4, 20, N'Lotus du Costa Rica, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (13, 4, 21, N'30m de haut pour ce Ceiba Pentandra de 400 ans, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (14, 4, 22, N'Nymphée odorante du Costa Rica, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (15, 4, 23, N'Forêt tropicale humide du Costa Rica, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (16, 4, 24, N'Orchidée, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (17, 4, 25, N'Orchidée, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (18, 3, 17, N'Traversée du pont Darwin entre le Zimbabwe et la Zambie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (19, 3, 16, N'Trucks of Guatemala.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (20, 2, 15, N'Enfants Himbas, peuple autochtone bantou, Namibie.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (21, 1, 1, N'Crocodile américain dans le chiapas, Amérique Centrale.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (22, 1, 2, N'Chat-thérapie, méditation et zenitude.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (23, 1, 3, N'Le grand koudou, Afrique du Sud.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (24, 1, 4, N'Rhinocéros blanc, Afrique du Sud.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (25, 1, 5, N'Zèbres dans le désert du Kalahari au Sud du Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (26, 1, 6, N'Hippopotame au nord du delta de l Okavango, Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (27, 1, 7, N'Zèbres dans le désert du Kalahari au Sud du Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (28, 1, 8, N'Chobe National Park, le royaume des éléphants, Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (29, 1, 9, N'Phacochères commun, Afrique du Sud.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (30, 1, 10, N'Girafe du Sud dans le parc de Chobe, Botswana.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (31, 1, 11, N'Le plus grand lézard d Afrique, le Varan du Nil.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (32, 7, 14, N'Éléphant de savane d Afrique.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (33, 7, 13, N'Damalisque à front blanc (Blesbok), Afrique du Sud.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
INSERT [dbo].[Albums] ([AlbumId], [CategorieId], [PhotoId], [Title], [Prix], [UrlMiniature]) VALUES (34, 7, 12, N'L hippopotame menaçant et menacé, Afrique.', CAST(1.00 AS Numeric(10, 2)), N'/Content/Images/placeholder.gif')
SET IDENTITY_INSERT [dbo].[Albums] OFF



Thanks for your help..
   
Comments
Richard Deeming 16-Mar-22 4:48am
   
If you want to update your question, click the green "Improve question" link and update your question.

Do not post your update as a "solution" to your question.
LSB71 16-Mar-22 5:19am
   
If necessary, I could work in CRUD with C# from three tables (Type, Size and Price) but how to send the sums obtained in the file (ShoppingCart.cs)… ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900