You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tinyPos/TinyPOS/TinyPosEntity/EntityController.cs

60 lines
1.9 KiB

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TinyPosEntity.Entity;
using TinyPosEntity.Service;
namespace TinyPosEntity
{
public class EntityController
{
public static string ConnectionString { get; set; }
private static EntityController instance;
public static EntityController Instance { get { Init(); return instance; } }
private EntityController(string connectionString)
{
EntityContext.ConnectionString = connectionString;
}
private static void Init()
{
if (string.IsNullOrEmpty(ConnectionString))
throw new Exception("ConnectionString 값이 필요합니다.");
if (instance == null)
instance = new EntityController(ConnectionString);
}
public void InitializeDatabase()
{
Database.SetInitializer<EntityContext>(new EntityInitializer());
using (EntityContext context = new EntityContext())
{
context.Database.CreateIfNotExists();
}
3 years ago
ProductTypeService.Instance.Create(GetDefaultProductTypes());
}
3 years ago
private List<ProductType> GetDefaultProductTypes()
{
3 years ago
List<ProductType> productTypeList = new List<ProductType>();
productTypeList.Add(new ProductType() { Name = "담배" });
productTypeList.Add(new ProductType() { Name = "주류" });
productTypeList.Add(new ProductType() { Name = "음료" });
productTypeList.Add(new ProductType() { Name = "과자" });
productTypeList.Add(new ProductType() { Name = "식료품" });
productTypeList.Add(new ProductType() { Name = "잡화" });
productTypeList.Add(new ProductType() { Name = "기타" });
3 years ago
return productTypeList;
}
}
}