Initial commit
Initial commit til Git. V2 er deployed
This commit is contained in:
62
PointOfSale/Pos.Ui/Database/Repository/EmployeeRepository.cs
Normal file
62
PointOfSale/Pos.Ui/Database/Repository/EmployeeRepository.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Database.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Database.Repository
|
||||
{
|
||||
public class EmployeeRepository : IDisposable
|
||||
{
|
||||
|
||||
public void Add(string name)
|
||||
{
|
||||
EmployeeEntity employee = new EmployeeEntity();
|
||||
employee.Name = name;
|
||||
employee.IsModified = true;
|
||||
using PosDbContext context = new PosDbContext();
|
||||
context.Employee.Add(employee);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public EmployeeEntity Get(int employeeId)
|
||||
{
|
||||
using PosDbContext context = new PosDbContext();
|
||||
EmployeeEntity employeeEntity = context.Employee.First(c => c.Id == employeeId);
|
||||
return employeeEntity;
|
||||
}
|
||||
|
||||
public List<EmployeeEntity> GetAll()
|
||||
{
|
||||
using PosDbContext context = new PosDbContext();
|
||||
List<EmployeeEntity> staffs = context.Employee.Where(c => c.IsArchived == false).ToList();
|
||||
|
||||
return staffs;
|
||||
}
|
||||
|
||||
public void Edit(int id, string name)
|
||||
{
|
||||
using PosDbContext context = new PosDbContext();
|
||||
EmployeeEntity employee = context.Employee.Single(c => c.Id == id);
|
||||
employee.Name = name;
|
||||
employee.IsModified = true;
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
using PosDbContext context = new PosDbContext();
|
||||
EmployeeEntity employee = context.Employee.Single(c => c.Id == id);
|
||||
employee.IsArchived = true;
|
||||
employee.IsModified = true;
|
||||
context.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user