RepositoryModel implemented
This commit is contained in:
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29609.76
|
VisualStudioVersion = 16.0.29609.76
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H_PLUS_Sports", "H_PLUS_Sports\H_PLUS_Sports.csproj", "{A5EEAD5D-227A-482E-AD66-F17D87C1E187}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H_Plus_Sports", "H_PLUS_Sports\H_Plus_Sports.csproj", "{A5EEAD5D-227A-482E-AD66-F17D87C1E187}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
19
H_PLUS_Sports/Contracts/ICustomerRepository.cs
Normal file
19
H_PLUS_Sports/Contracts/ICustomerRepository.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Contracts
|
||||||
|
{
|
||||||
|
public interface ICustomerRepository
|
||||||
|
{
|
||||||
|
Task<Customer> Add(Customer customer);
|
||||||
|
IEnumerable<Customer> GetAll();
|
||||||
|
Task<Customer> Find(int id);
|
||||||
|
Task<Customer> Update(Customer customer);
|
||||||
|
Task<Customer> Remove(int id);
|
||||||
|
Task<bool> Exist(int id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
21
H_PLUS_Sports/Contracts/IOrderItemRepository.cs
Normal file
21
H_PLUS_Sports/Contracts/IOrderItemRepository.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Contracts
|
||||||
|
{
|
||||||
|
public interface IOrderItemRepository
|
||||||
|
{
|
||||||
|
Task<OrderItem> Add(OrderItem item);
|
||||||
|
|
||||||
|
IEnumerable<OrderItem> GetAll();
|
||||||
|
|
||||||
|
Task<OrderItem> Find(int id);
|
||||||
|
|
||||||
|
Task<OrderItem> Remove(int id);
|
||||||
|
|
||||||
|
Task<OrderItem> Update(OrderItem item);
|
||||||
|
|
||||||
|
Task<bool> Exists(int id);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
H_PLUS_Sports/Contracts/IOrderRepository.cs
Normal file
21
H_PLUS_Sports/Contracts/IOrderRepository.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Contracts
|
||||||
|
{
|
||||||
|
public interface IOrderRepository
|
||||||
|
{
|
||||||
|
Task<Order> Add(Order item);
|
||||||
|
|
||||||
|
IEnumerable<Order> GetAll();
|
||||||
|
|
||||||
|
Task<Order> Find(int id);
|
||||||
|
|
||||||
|
Task<Order> Remove(int id);
|
||||||
|
|
||||||
|
Task<Order> Update(Order item);
|
||||||
|
|
||||||
|
Task<bool> Exists(int id);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
H_PLUS_Sports/Contracts/IProductRepository.cs
Normal file
21
H_PLUS_Sports/Contracts/IProductRepository.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Contracts
|
||||||
|
{
|
||||||
|
public interface IProductRepository
|
||||||
|
{
|
||||||
|
Task<Product> Add(Product item);
|
||||||
|
|
||||||
|
IEnumerable<Product> GetAll();
|
||||||
|
|
||||||
|
Task<Product> Find(string id);
|
||||||
|
|
||||||
|
Task<Product> Remove(string id);
|
||||||
|
|
||||||
|
Task<Product> Update(Product item);
|
||||||
|
|
||||||
|
Task<bool> Exists(string id);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
H_PLUS_Sports/Contracts/ISalespersonRepository.cs
Normal file
21
H_PLUS_Sports/Contracts/ISalespersonRepository.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Contracts
|
||||||
|
{
|
||||||
|
public interface ISalespersonRepository
|
||||||
|
{
|
||||||
|
Task<Salesperson> Add(Salesperson item);
|
||||||
|
|
||||||
|
IEnumerable<Salesperson> GetAll();
|
||||||
|
|
||||||
|
Task<Salesperson> Find(int id);
|
||||||
|
|
||||||
|
Task<Salesperson> Remove(int id);
|
||||||
|
|
||||||
|
Task<Salesperson> Update(Salesperson item);
|
||||||
|
|
||||||
|
Task<bool> Exists(int id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
|
|
||||||
namespace HPlusSportsAPI.Controllers
|
namespace HPlusSportsAPI.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
|
|
||||||
namespace HPlusSportsAPI.Controllers
|
namespace HPlusSportsAPI.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
|
|
||||||
namespace HPlusSportsAPI.Controllers
|
namespace HPlusSportsAPI.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
|
|
||||||
namespace HPlusSportsAPI.Controllers
|
namespace HPlusSportsAPI.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
|
|
||||||
namespace HPlusSportsAPI.Controllers
|
namespace HPlusSportsAPI.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class Customer
|
public partial class Customer
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class H_Plus_SportsContext : DbContext
|
public partial class H_Plus_SportsContext : DbContext
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class Order
|
public partial class Order
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class OrderItem
|
public partial class OrderItem
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class Product
|
public partial class Product
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace H_PLUS_Sports.Models
|
namespace H_Plus_Sports.Models
|
||||||
{
|
{
|
||||||
public partial class Salesperson
|
public partial class Salesperson
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace H_PLUS_Sports
|
namespace H_Plus_Sports
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|||||||
57
H_PLUS_Sports/Repositories/CustomerRepository.cs
Normal file
57
H_PLUS_Sports/Repositories/CustomerRepository.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using H_Plus_Sports.Contracts;
|
||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Repositories
|
||||||
|
{
|
||||||
|
public class CustomerRepository : ICustomerRepository
|
||||||
|
{
|
||||||
|
private H_Plus_SportsContext _context;
|
||||||
|
|
||||||
|
public CustomerRepository(H_Plus_SportsContext context )
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Customer> Add(Customer customer)
|
||||||
|
{
|
||||||
|
await _context.Customer.AddAsync(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exist(int id)
|
||||||
|
{
|
||||||
|
return await _context.Customer.AnyAsync(x => x.CustomerId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Customer> Find(int id)
|
||||||
|
{
|
||||||
|
return await _context.Customer.Include(customer => customer.Order).SingleOrDefaultAsync(a => a.CustomerId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Customer> GetAll()
|
||||||
|
{
|
||||||
|
return _context.Customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Customer> Remove(int id)
|
||||||
|
{
|
||||||
|
var customer = await _context.Customer.SingleAsync(a => a.CustomerId == id);
|
||||||
|
_context.Customer.Remove(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Customer> Update(Customer customer)
|
||||||
|
{
|
||||||
|
_context.Customer.Update(customer);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
H_PLUS_Sports/Repositories/OrderItemRepository.cs
Normal file
55
H_PLUS_Sports/Repositories/OrderItemRepository.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using H_Plus_Sports.Contracts;
|
||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Repositories
|
||||||
|
{
|
||||||
|
public class OrderItemRepository : IOrderItemRepository
|
||||||
|
{
|
||||||
|
private H_Plus_SportsContext _context;
|
||||||
|
|
||||||
|
public OrderItemRepository(H_Plus_SportsContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<OrderItem> GetAll()
|
||||||
|
{
|
||||||
|
return _context.OrderItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OrderItem> Add(OrderItem orderItem)
|
||||||
|
{
|
||||||
|
await _context.OrderItem.AddAsync(orderItem);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return orderItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OrderItem> Find(int id)
|
||||||
|
{
|
||||||
|
return await _context.OrderItem.Include(orderItem => orderItem.Order).Include(orderItem => orderItem.Product).SingleOrDefaultAsync(a => a.OrderItemId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OrderItem> Remove(int id)
|
||||||
|
{
|
||||||
|
var orderItem = await _context.OrderItem.SingleAsync(a => a.OrderItemId == id);
|
||||||
|
_context.OrderItem.Remove(orderItem);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return orderItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<OrderItem> Update(OrderItem orderItem)
|
||||||
|
{
|
||||||
|
_context.OrderItem.Update(orderItem);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return orderItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exists(int id)
|
||||||
|
{
|
||||||
|
return await _context.OrderItem.AnyAsync(e => e.OrderItemId == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
H_PLUS_Sports/Repositories/OrderRepository.cs
Normal file
56
H_PLUS_Sports/Repositories/OrderRepository.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using H_Plus_Sports.Contracts;
|
||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Repositories
|
||||||
|
{
|
||||||
|
public class OrderRepository : IOrderRepository
|
||||||
|
{
|
||||||
|
private H_Plus_SportsContext _context;
|
||||||
|
|
||||||
|
public OrderRepository(H_Plus_SportsContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Order> GetAll()
|
||||||
|
{
|
||||||
|
return _context.Order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Order> Add(Order order)
|
||||||
|
{
|
||||||
|
await _context.Order.AddAsync(order);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Order> Find(int id)
|
||||||
|
{
|
||||||
|
return await _context.Order.Include(order => order.OrderItem).Include(order => order.Customer).SingleOrDefaultAsync(a => a.OrderId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Order> Remove(int id)
|
||||||
|
{
|
||||||
|
var order = _context.Order.Single(a => a.OrderId == id);
|
||||||
|
_context.Order.Remove(order);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Order> Update(Order order)
|
||||||
|
{
|
||||||
|
_context.Order.Update(order);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exists(int id)
|
||||||
|
{
|
||||||
|
return await _context.Order.AnyAsync(e => e.OrderId == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
H_PLUS_Sports/Repositories/ProductRepository.cs
Normal file
55
H_PLUS_Sports/Repositories/ProductRepository.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using H_Plus_Sports.Contracts;
|
||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Repositories
|
||||||
|
{
|
||||||
|
public class ProductRepository : IProductRepository
|
||||||
|
{
|
||||||
|
private H_Plus_SportsContext _context;
|
||||||
|
|
||||||
|
public ProductRepository(H_Plus_SportsContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Product> GetAll()
|
||||||
|
{
|
||||||
|
return _context.Product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Product> Add(Product product)
|
||||||
|
{
|
||||||
|
await _context.Product.AddAsync(product);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Product> Find(string id)
|
||||||
|
{
|
||||||
|
return await _context.Product.Include(product => product.OrderItem).SingleOrDefaultAsync(a => a.ProductId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Product> Remove(string id)
|
||||||
|
{
|
||||||
|
var product = await _context.Product.SingleAsync(a => a.ProductId == id);
|
||||||
|
_context.Product.Remove(product);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Product> Update(Product product)
|
||||||
|
{
|
||||||
|
_context.Product.Update(product);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exists(string id)
|
||||||
|
{
|
||||||
|
return await _context.Product.AnyAsync(e => e.ProductId == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
H_PLUS_Sports/Repositories/SalespersonRepository.cs
Normal file
55
H_PLUS_Sports/Repositories/SalespersonRepository.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using H_Plus_Sports.Contracts;
|
||||||
|
using H_Plus_Sports.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace H_Plus_Sports.Repositories
|
||||||
|
{
|
||||||
|
public class SalespersonRepository : ISalespersonRepository
|
||||||
|
{
|
||||||
|
private H_Plus_SportsContext _context;
|
||||||
|
|
||||||
|
public SalespersonRepository(H_Plus_SportsContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Salesperson> GetAll()
|
||||||
|
{
|
||||||
|
return _context.Salesperson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Salesperson> Add(Salesperson salesperson)
|
||||||
|
{
|
||||||
|
await _context.Salesperson.AddAsync(salesperson);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return salesperson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Salesperson> Find(int id)
|
||||||
|
{
|
||||||
|
return await _context.Salesperson.Include(salesperson => salesperson.Order).SingleOrDefaultAsync(a => a.SalespersonId == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Salesperson> Remove(int id)
|
||||||
|
{
|
||||||
|
var salesperson = await _context.Salesperson.SingleAsync(a => a.SalespersonId == id);
|
||||||
|
_context.Salesperson.Remove(salesperson);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return salesperson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Salesperson> Update(Salesperson salesperson)
|
||||||
|
{
|
||||||
|
_context.Salesperson.Update(salesperson);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return salesperson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exists(int id)
|
||||||
|
{
|
||||||
|
return await _context.Order.AnyAsync(e => e.OrderId == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using H_PLUS_Sports.Models;
|
using H_Plus_Sports.Models;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
using Microsoft.AspNetCore.HttpsPolicy;
|
||||||
@ -13,7 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace H_PLUS_Sports
|
namespace H_Plus_Sports
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace H_PLUS_Sports
|
namespace H_Plus_Sports
|
||||||
{
|
{
|
||||||
public class WeatherForecast
|
public class WeatherForecast
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user