Product Context
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Business.Business.Sales
|
||||
{
|
||||
interface ISalesController<T>
|
||||
{
|
||||
ICollection<T> GetAll();
|
||||
T Get(int id);
|
||||
ICollection<T> GetByTime(byte[] startPeriod, byte[] endPeriod);
|
||||
void Add(int productId, double Amount);
|
||||
void Add(string productName, double Amount);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Business.Business.Sales
|
||||
{
|
||||
interface IStockController<T>
|
||||
{
|
||||
ICollection<T> GetAll();
|
||||
T GetById(int id);
|
||||
T GetByName(string name);
|
||||
void AddProduct(T product);
|
||||
void LoadProductByName(T product);
|
||||
void LoadProductById(int id);
|
||||
void Sale(int id);
|
||||
void Sale(string name);
|
||||
|
||||
}
|
||||
}
|
78
LuminousSales/Business/Business/Sales/ProductController.cs
Normal file
78
LuminousSales/Business/Business/Sales/ProductController.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Business.Business.UserManagment;
|
||||
using Models;
|
||||
using Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Business.Business.Sales
|
||||
{
|
||||
class ProductController : IController<Product>
|
||||
{
|
||||
private LuminousContext context = new LuminousContext();
|
||||
private User currentUser;
|
||||
public ProductController(User currenUser)
|
||||
{
|
||||
this.currentUser = currenUser;
|
||||
}
|
||||
public ICollection<Product> GetAll()
|
||||
{
|
||||
return context.Product.ToList();
|
||||
}
|
||||
public Product Get(int id)
|
||||
{
|
||||
return context.Product.Find(id);
|
||||
}
|
||||
public Product Get(string name)
|
||||
{
|
||||
return context.Product.FirstOrDefault(p => p.Name == name);
|
||||
}
|
||||
public ICollection<Product> GetByApproximateName(string name)
|
||||
{
|
||||
return context.Product.Where(u => u.Name.Contains(name)).ToList();
|
||||
}
|
||||
public void AddItem(string name, double price)
|
||||
{
|
||||
var product = new Product(name, price);
|
||||
context.Product.Add(product);
|
||||
}
|
||||
public void UpdateName(int id, string newName)
|
||||
{
|
||||
if (currentUser.RoleId > 1)
|
||||
{
|
||||
var product = Get(id);
|
||||
if (product != null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateName(string oldName, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void UpdatePrice(int id)
|
||||
{
|
||||
|
||||
}
|
||||
public void UpdatePrice(string name)
|
||||
{
|
||||
|
||||
}
|
||||
public void Delete(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Delete(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -30,12 +30,14 @@ namespace Business.Business.UserManagment
|
||||
{
|
||||
return context.User.FirstOrDefault(u => u.Name == name);
|
||||
}
|
||||
public void ValidatePassword(string password)
|
||||
public User ValidatePassword(string password)
|
||||
{
|
||||
if (!GetAll().Where(u => u.Password == password).Any())
|
||||
var user = context.User.FirstOrDefault();
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentException("Invalid User!");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
public ICollection<User> GetByApproximateName(string name)
|
||||
{
|
||||
|
Reference in New Issue
Block a user