Exemple #1
0
        // delete
        // update
        public static bool hiddenMenu(int id)
        {
            var result = false;

            MMenuVM data = MMenuRepo.getById(id);

            using (AppEntity db = new AppEntity())
            {
                m_menu item = db.m_menu.Find(id);

                item.is_active    = false;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
Exemple #2
0
        public static bool insert(MMenuAccessVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                foreach (var item in model.listMenuId)
                {
                    var data = new m_menu_access()
                    {
                        m_role_id    = model.role.id,
                        created_by   = 2,
                        is_active    = true,
                        created_date = DateTime.Now,
                        m_menu_id    = item
                    };
                    db.m_menu_access.Add(data);
                }
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #3
0
        //insert
        //menerima view model dari view
        public static bool insert(MRoleVM model)
        {
            bool result = false;

            //simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                m_role item = new m_role()
                {
                    id           = model.id,
                    code         = model.code,
                    name         = model.name,
                    description  = model.description,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    updated_by   = 1,
                    updated_date = DateTime.Now,
                };
                db.m_role.Add(item);

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
Exemple #4
0
        //insert
        //menerima view model dari view
        public static bool insert(MMenuVM model)
        {
            bool result = false;

            //simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                m_menu item = new m_menu()
                {
                    id           = model.id,
                    code         = model.code,
                    name         = model.name,
                    controller   = model.controller,
                    parent_id    = model.parent_id,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    updated_by   = 1,
                    updated_date = DateTime.Now,
                };
                db.m_menu.Add(item);

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
Exemple #5
0
        public static bool update(MUserVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                var data = db.m_user.Find(model.id);
                data.id            = model.id;
                data.m_employee_id = model.mEmployeeId;
                data.m_role_id     = model.mRoleId;
                data.username      = model.username;
                data.password      = model.password;
                data.updated_by    = model.updatedBy;
                data.updated_date  = DateTime.Now;
                data.is_active     = true;
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #6
0
        public static bool insert(MUserVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                model.isActive = true;
                m_user data = new m_user()
                {
                    m_employee_id = model.mEmployeeId,
                    m_role_id     = model.mRoleId,
                    username      = model.username,
                    password      = model.password,
                    created_by    = model.createdBy,
                    created_date  = DateTime.Now,
                    is_active     = model.isActive
                };
                db.m_user.Add(data);
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #7
0
        public static bool update(MMenuAccessVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                var dataMenu = db.m_menu_access.Where(x => x.m_role_id == model.role.id);
                db.m_menu_access.RemoveRange(dataMenu);
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
                //memasukan idMenu Baru
                foreach (var item in model.listMenuId)
                {
                    m_menu_access data = new m_menu_access()
                    {
                        m_role_id    = model.role.id,
                        m_menu_id    = item,
                        created_by   = 2,
                        created_date = DateTime.Now,
                        is_active    = true
                    };
                    db.m_menu_access.Add(data);
                }
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
        public static bool Delete(int id)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_employee item = db.m_employee.Find(id);
                item.is_active    = false;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }

            return(result);
        }
        public static bool Delete(MCompanyVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_company item = db.m_company.Find(model.id);
                item.is_active    = false;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }

            return(result);
        }
Exemple #10
0
        // update
        public static bool update(mUnitVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_unit item = db.m_unit.Find(model.id);
                item.code         = model.code;
                item.name         = model.name;
                item.description  = model.description;
                item.updated_by   = 2;
                item.updated_date = DateTime.Now.Date;
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }
Exemple #11
0
        public static bool Update(MProductVM model)
        {
            bool res = false;

            using (AppEntity db = new AppEntity())
            {
                m_product data = db.m_product.Find(model.id);
                data.code         = model.code;
                data.name         = model.name;
                data.description  = model.description;
                data.updated_by   = 1;
                data.updated_date = DateTime.Now;

                try { db.SaveChanges(); res = true; } catch (Exception) { throw; }
            }
            return(res);
        }
Exemple #12
0
        public static bool Delete(int id)
        {
            bool res = false;

            using (AppEntity db = new AppEntity())
            {
                m_product data = db.m_product.Find(id);
                data.id           = data.id;
                data.code         = data.code;
                data.name         = data.name;
                data.is_active    = false;
                data.updated_by   = 1;
                data.updated_date = DateTime.Now;

                try { db.SaveChanges(); res = true; } catch (Exception) { throw; }
            }
            return(res);
        }
Exemple #13
0
        // delete

        public static bool HideUnit(int id)
        {
            var result = false;

            mUnitVM data = mUnitRepo.getById(id);

            using (AppEntity db = new AppEntity())
            {
                m_role item = db.m_role.Find(id);

                item.is_active    = false;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;

                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }

            return(result);
        }
        public static bool update(MCompanyVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_company item = db.m_company.Find(model.id);
                item.id           = model.id;
                item.code         = model.code;
                item.name         = model.name;
                item.address      = model.address;
                item.phone        = model.phone;
                item.is_active    = true;
                item.email        = model.email;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }
Exemple #15
0
        // update
        public static bool Edit(MRoleVM model)
        {
            bool result = false;

            // simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                // get data dari database
                m_role item = db.m_role.Find(model.id);
                item.id           = model.id;
                item.code         = model.code;
                item.name         = model.name;
                item.description  = model.description;
                item.updated_by   = 1;
                item.updated_date = DateTime.Now;
                try { db.SaveChanges(); result = true; }
                catch (Exception) { throw; }
            }
            return(result);
        }
        public static bool update(MEmployeeVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_employee item = db.m_employee.Find(model.id);
                item.employee_number = model.employee_number;
                item.first_name      = model.first_name;
                item.last_name       = model.last_name;
                item.m_company_id    = model.m_company_id;

                item.email        = model.email;
                item.is_active    = true;
                item.created_by   = 1;
                item.created_date = DateTime.Now;
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }
Exemple #17
0
        public static bool delete(int id)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                var data = db.m_user.Find(id);
                data.is_active = false;
                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #18
0
        public static bool Insert(MProductVM model, string userID)
        {
            bool res = false;

            using (AppEntity db = new AppEntity())
            {
                m_product data = new m_product()
                {
                    code         = model.code,
                    name         = model.name,
                    description  = model.description,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    is_active    = true
                };

                db.m_product.Add(data);
                try { db.SaveChanges(); res = true; } catch (Exception) { throw; }
            }
            return(res);
        }
Exemple #19
0
        // update
        public static bool Edit(MMenuVM model)
        {
            bool result = false;

            // simpan datanya ke model
            using (AppEntity db = new AppEntity())
            {
                // get data dari database
                m_menu item = db.m_menu.Find(model.id);
                item.id           = model.id;
                item.code         = model.code;
                item.name         = model.name;
                item.controller   = model.controller;
                item.parent_id    = model.parent_id;
                item.updated_by   = model.updated_by;
                item.updated_date = model.updated_date;
                try { db.SaveChanges(); result = true; }
                catch (Exception) { throw; }
            }
            return(result);
        }
        public static bool Insert(MSouvenirVM model)
        {
            bool res = false;

            using (AppEntity db = new AppEntity())
            {
                m_souvenir data = new m_souvenir()
                {
                    code         = model.code,
                    name         = model.name,
                    description  = model.description,
                    m_unit_id    = model.m_unit_id,
                    created_by   = 1,
                    created_date = DateTime.Now,
                    is_active    = true
                };

                db.m_souvenir.Add(data);
                try { db.SaveChanges(); res = true; } catch (Exception) { throw; }
            }
            return(res);
        }
Exemple #21
0
        public static bool insert(mUnitVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_unit item = new m_unit()
                {
                    code         = model.code,
                    name         = model.name,
                    description  = model.description,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now.Date,
                    updated_by   = 1,
                    updated_date = DateTime.Now.Date,
                };
                db.m_unit.Add(item);
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }
        public static bool insert(MCompanyVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_company item = new m_company()
                {
                    code         = model.code,
                    name         = model.name,
                    address      = model.address,
                    phone        = model.phone,
                    email        = model.email,
                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now
                };
                db.m_company.Add(item);
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }
        public static bool insert(MEmployeeVM model)
        {
            bool result = false;

            using (AppEntity db = new AppEntity())
            {
                m_employee item = new m_employee()
                {
                    employee_number = model.employee_number,
                    first_name      = model.first_name,
                    last_name       = model.last_name,
                    m_company_id    = model.m_company_id,
                    email           = model.email,

                    is_active    = true,
                    created_by   = 1,
                    created_date = DateTime.Now
                };
                db.m_employee.Add(item);
                try { db.SaveChanges(); result = true; } catch (Exception) { throw; }
            }
            return(result);
        }