Пример #1
0
        public static x_role GetAllDatabyId(long ID)
        {
            x_role output = new x_role();

            using (DBSpecEntities db = new DBSpecEntities())
            {
                output = db.x_role.Where(a => a.id == ID).FirstOrDefault();
            }
            return(output);
        }
Пример #2
0
        public static string checkdataDuplicate(string rawData)
        {
            x_role data = new x_role();

            using (DBSpecEntities db = new DBSpecEntities())
            {
                data = db.x_role.Where(a => a.code.Contains(rawData)).FirstOrDefault();
                if (data != null)
                {
                    return("ada");
                }
                else
                {
                    return("tidak");
                }
            }
        }
Пример #3
0
        public static bool SaveData(x_role newData, long created)
        {
            try
            {
                using (DBSpecEntities db = new DBSpecEntities())
                {
                    newData.created_by = created;
                    newData.created_on = System.DateTime.Now;
                    newData.is_delete  = false;

                    db.x_role.Add(newData);

                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #4
0
        public static bool DeleteData(long id, long deleteby)
        {
            try
            {
                using (DBSpecEntities db = new DBSpecEntities())
                {
                    x_role data = GetAllDatabyId(id);
                    data.is_delete  = true;
                    data.deleted_by = deleteby;
                    data.deleted_on = System.DateTime.Now;

                    db.Entry(data).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #5
0
        public static bool UpdateData(x_role newData, long updatedby)
        {
            try
            {
                using (DBSpecEntities db = new DBSpecEntities())
                {
                    x_role oldData = GetAllDatabyId(newData.id);


                    oldData.modified_by     = updatedby;
                    oldData.modified_on     = System.DateTime.Now;
                    oldData.code            = newData.code;
                    oldData.name            = newData.name;
                    db.Entry(oldData).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }