Exemple #1
0
 public EFUnitOfWork(string connectionString)
 {
     db            = new VapeContext(connectionString);
     userManager   = new ApplicationUserManager(new UserStore <ApplicationUser>(db));
     roleManager   = new ApplicationRoleManager(new RoleStore <ApplicationRole>(db));
     clientManager = new ClientManager(db);
 }
        public static List <VarianViewModel> GetAll()
        {
            List <VarianViewModel> result = new List <VarianViewModel>();

            using (var db = new VapeContext())
            {
                result = (from var in db.Mst_Varian
                          join ite in db.Mst_Item on var.ItemCode equals ite.ItemCode
                          select new VarianViewModel
                {
                    Id = var.Id,
                    VarianCode = var.VarianCode,
                    VarianName = var.VarianName,
                    ItemCode = var.ItemCode,
                    ItemName = ite.ItemName,
                    Country = var.Country,
                    Strength = var.Strength,
                    PGVG = var.PGVG,
                    Size = var.Size,
                    Price = var.Price,
                    Unit = var.Unit,
                    IsActive = var.IsActive,
                }).ToList();
            }
            return(result);
        }
        public static VarianViewModel GetById(int id)
        {
            VarianViewModel result = new VarianViewModel();

            using (var db = new VapeContext())
            {
                result = (from var in db.Mst_Varian
                          join ite in db.Mst_Item on var.ItemCode equals ite.ItemCode into itelf
                          from ite in itelf.DefaultIfEmpty()
                          join cat in db.Mst_Category on ite.CategoryCode equals cat.CategoryCode into catlf
                          from cat in catlf.DefaultIfEmpty()
                          where var.Id == id
                          select new VarianViewModel
                {
                    Id = var.Id,
                    VarianCode = var.VarianCode,
                    VarianName = var.VarianName,
                    CategoryCode = ite.CategoryCode,
                    ItemCode = var.ItemCode,
                    ItemName = ite.ItemName,
                    Country = var.Country,
                    Strength = var.Strength,
                    PGVG = var.PGVG,
                    Size = var.Size,
                    Price = var.Price,
                    Unit = var.Unit,
                    IsActive = var.IsActive,
                }).FirstOrDefault();
            }
            return(result);
        }
        public static bool Update(VarianViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    if (model.Id == 0)
                    {
                        Mst_Varian var = new Mst_Varian();
                        var.VarianCode = model.VarianCode;
                        var.VarianName = model.VarianName;
                        var.ItemCode   = model.ItemCode;
                        var.Country    = model.Country;
                        var.Strength   = model.Strength;
                        var.PGVG       = model.PGVG;
                        var.Size       = model.Size;
                        var.Price      = model.Price;
                        var.Unit       = model.Unit;
                        var.IsActive   = model.IsActive;

                        db.Mst_Varian.Add(var);
                        db.SaveChanges();
                    }
                    else
                    {
                        Mst_Varian var = db.Mst_Varian.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (var != null)
                        {
                            var.VarianCode = model.VarianCode;
                            var.VarianName = model.VarianName;
                            var.ItemCode   = model.ItemCode;
                            var.Country    = model.Country;
                            var.Strength   = model.Strength;
                            var.PGVG       = model.PGVG;
                            var.Size       = model.Size;
                            var.Price      = model.Price;
                            var.Unit       = model.Unit;
                            var.IsActive   = model.IsActive;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #5
0
        public static List <CategoryViewModel> GetAll()
        {
            List <CategoryViewModel> result = new List <CategoryViewModel>();

            using (var db = new VapeContext())
            {
                result = (from cat in db.Mst_Category
                          select new CategoryViewModel
                {
                    Id = cat.Id,
                    CategoryCode = cat.CategoryCode,
                    CategoryName = cat.CategoryName,
                    IsActive = cat.IsActive
                }).ToList();
            }
            return(result);
        }
Exemple #6
0
        public static CategoryViewModel GetById(int id)
        {
            CategoryViewModel result = new CategoryViewModel();

            using (var db = new VapeContext())
            {
                result = (from cat in db.Mst_Category
                          where cat.Id == id
                          select new CategoryViewModel
                {
                    Id = cat.Id,
                    CategoryCode = cat.CategoryCode,
                    CategoryName = cat.CategoryName,
                    IsActive = cat.IsActive
                }).FirstOrDefault();
            }
            return(result);
        }
Exemple #7
0
        public static bool Update(ItemViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    if (model.Id == 0)
                    {
                        Mst_Item ite = new Mst_Item();
                        ite.ItemCode     = model.ItemCode;
                        ite.ItemName     = model.ItemName;
                        ite.CategoryCode = model.CategoryCode;
                        ite.Description  = model.Description;
                        ite.Stock        = ite.Stock;
                        ite.IsActive     = model.IsActive;
                        db.Mst_Item.Add(ite);
                        db.SaveChanges();
                    }
                    else
                    {
                        Mst_Item ite = db.Mst_Item.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (ite != null)
                        {
                            ite.ItemCode     = model.ItemCode;
                            ite.ItemName     = model.ItemName;
                            ite.CategoryCode = model.CategoryCode;
                            ite.Description  = ite.Description;
                            ite.Stock        = ite.Stock;
                            ite.IsActive     = model.IsActive;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #8
0
        public static List <CustomerViewModel> GetAll()
        {
            List <CustomerViewModel> result = new List <CustomerViewModel>();

            using (var db = new VapeContext())
            {
                result = (from cus in db.Mst_Customer
                          select new CustomerViewModel
                {
                    Id = cus.Id,
                    CostumerName = cus.CostumerName,
                    Address = cus.Address,
                    Email = cus.Email,
                    Phone = cus.Phone,
                    IsActive = cus.IsActive
                }).ToList();
            }
            return(result);
        }
Exemple #9
0
        public static List <SupplierViewModel> GetAll()
        {
            List <SupplierViewModel> result = new List <SupplierViewModel>();

            using (var db = new VapeContext())
            {
                result = (from sup in db.Mst_Supplier
                          select new SupplierViewModel
                {
                    Id = sup.Id,
                    SupplierCode = sup.SupplierCode,
                    SupplierName = sup.SupplierName,
                    Address = sup.Address,
                    Phone = sup.Phone,
                    IsActive = sup.IsActive
                }).ToList();
            }
            return(result);
        }
Exemple #10
0
        public static bool Update(CustomerViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    if (model.Id == 0)
                    {
                        Mst_Customer cus = new Mst_Customer();
                        cus.CostumerName = model.CostumerName;
                        cus.Address      = model.Address;
                        cus.Email        = model.Email;
                        cus.Phone        = model.Phone;
                        cus.IsActive     = model.IsActive;
                        db.Mst_Customer.Add(cus);
                        db.SaveChanges();
                    }

                    else
                    {
                        Mst_Customer cus = db.Mst_Customer.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (cus != null)
                        {
                            cus.CostumerName = model.CostumerName;
                            cus.Address      = model.Address;
                            cus.Email        = model.Email;
                            cus.Phone        = model.Phone;
                            cus.IsActive     = model.IsActive;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #11
0
        public static SupplierViewModel GetById(int id)
        {
            SupplierViewModel result = new SupplierViewModel();

            using (var db = new VapeContext())
            {
                result = (from sup in db.Mst_Supplier
                          where sup.Id == id
                          select new SupplierViewModel
                {
                    Id = sup.Id,
                    SupplierCode = sup.SupplierCode,
                    SupplierName = sup.SupplierName,
                    Address = sup.Address,
                    Phone = sup.Phone,
                    IsActive = sup.IsActive
                }).FirstOrDefault();
            }
            return(result);
        }
Exemple #12
0
        public static CustomerViewModel GetById(int id)
        {
            CustomerViewModel result = new CustomerViewModel();

            using (var db = new VapeContext())
            {
                result = (from cus in db.Mst_Customer
                          where cus.Id == id
                          select new CustomerViewModel
                {
                    Id = cus.Id,
                    CostumerName = cus.CostumerName,
                    Address = cus.Address,
                    Email = cus.Email,
                    Phone = cus.Phone,
                    IsActive = cus.IsActive
                }).FirstOrDefault();
            }
            return(result);
        }
Exemple #13
0
        public static bool Update(SupplierViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    if (model.Id == 0)
                    {
                        Mst_Supplier sup = new Mst_Supplier();
                        sup.SupplierCode = model.SupplierCode;
                        sup.SupplierName = model.SupplierName;
                        sup.Address      = model.Address;
                        sup.Phone        = model.Phone;
                        sup.IsActive     = model.IsActive;
                        db.Mst_Supplier.Add(sup);
                        db.SaveChanges();
                    }
                    else
                    {
                        Mst_Supplier sup = db.Mst_Supplier.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (sup != null)
                        {
                            sup.SupplierCode = model.SupplierCode;
                            sup.SupplierName = model.SupplierName;
                            sup.Address      = model.Address;
                            sup.Phone        = model.Phone;
                            sup.IsActive     = model.IsActive;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #14
0
        public static List <ItemViewModel> GetAll()
        {
            List <ItemViewModel> result = new List <ItemViewModel>();

            using (var db = new VapeContext())
            {
                result = (from ite in db.Mst_Item
                          join cat in db.Mst_Category on ite.CategoryCode equals cat.CategoryCode
                          select new ItemViewModel
                {
                    Id = ite.Id,
                    ItemCode = ite.ItemCode,
                    ItemName = ite.ItemName,
                    CategoryCode = ite.CategoryCode,
                    CategoryName = cat.CategoryName,
                    Description = ite.Description,
                    Stock = ite.Stock,
                    IsActive = ite.IsActive
                }).ToList();
            }
            return(result);
        }
Exemple #15
0
        public static ItemViewModel GetById(int id)
        {
            ItemViewModel result = new ItemViewModel();

            using (var db = new VapeContext())
            {
                result = (from ite in db.Mst_Item
                          join cat in db.Mst_Category on ite.CategoryCode equals cat.CategoryCode
                          where ite.Id == id
                          select new ItemViewModel
                {
                    Id = ite.Id,
                    ItemCode = ite.ItemCode,
                    ItemName = ite.ItemName,
                    CategoryCode = ite.CategoryCode,
                    CategoryName = cat.CategoryName,
                    Description = ite.Description,
                    Stock = ite.Stock,
                    IsActive = ite.IsActive
                }).FirstOrDefault();
            }
            return(result);
        }
Exemple #16
0
        public static bool Delete(int id)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    Mst_Category cat = db.Mst_Category.Where(o => o.Id == id).FirstOrDefault();
                    if (cat != null)
                    {
                        db.Mst_Category.Remove(cat);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #17
0
        public static bool Update(CategoryViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new VapeContext())
                {
                    if (model.Id == 0)
                    {
                        Mst_Category cat = new Mst_Category();
                        cat.CategoryCode = model.CategoryCode;
                        cat.CategoryName = model.CategoryName;
                        cat.IsActive     = model.IsActive;
                        db.Mst_Category.Add(cat);
                        db.SaveChanges();
                    }
                    else
                    {
                        Mst_Category cat = db.Mst_Category.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (cat != null)
                        {
                            cat.CategoryCode = model.CategoryCode;
                            cat.CategoryName = model.CategoryName;
                            cat.IsActive     = model.IsActive;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }
Exemple #18
0
 public ImageBoxModRepository(VapeContext context)
 {
     this.db = context;
 }
Exemple #19
0
 public FullVapeRepository(VapeContext context)
 {
     this.db = context;
 }
 public ImageFluidRepository(VapeContext context)
 {
     this.db = context;
 }
Exemple #21
0
 public OrderRepository(VapeContext context)
 {
     this.db = context;
 }
Exemple #22
0
 public TankRepository(VapeContext context)
 {
     this.db = context;
 }
Exemple #23
0
 public MechModRepository(VapeContext context)
 {
     this.db = context;
 }
 public ImageDripRepository(VapeContext context)
 {
     this.db = context;
 }
Exemple #25
0
 public ClientManager(VapeContext db)
 {
     Database = db;
 }