Exemple #1
0
        public Role_Data GetRoles(int ID)
        {
            Role_Data result = new Role_Data();
            Role      role;

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    if (!this.existRoles(ID))
                    {
                        result = null;
                        return(result);
                    }
                    role               = construyeEntities.Roles.Find(ID);
                    result.id          = role.id;
                    result.id_employee = role.id_employee;
                    result.id_role     = role.id_role;
                    result.start_date  = role.start_date;
                    return(result);
                }
                catch (Exception E)
                {
                    result = null;
                    return(result);
                }
            }
        }
Exemple #2
0
 public bool updateRoles(Role_Data data)
 {
     using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
     {
         try
         {
             var role = construyeEntities.Roles.Find(data.id_role);
             role.id_role            = data.id_role;
             role.id_employee        = data.id_employee;
             role.start_date         = data.start_date;
             role.Role_specification = construyeEntities.Role_specification.Find(data.id_role);
             role.Employee           = construyeEntities.Employees.Find(data.id_employee);
             construyeEntities.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Exemple #3
0
        public List <Object> GetListRoles()
        {
            List <Object> dataList = new List <object>();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    var providerList = construyeEntities.Roles.ToList();
                    int n            = providerList.Count;
                    if (n == 0)
                    {
                        dataList = null;
                        return(dataList);
                    }
                    else
                    {
                        for (int i = 0; i < providerList.Count; ++i)
                        {
                            Role_Data data = new Role_Data();
                            data.id          = providerList.ElementAt(i).id;
                            data.id_employee = providerList.ElementAt(i).id_employee;
                            data.id_role     = providerList.ElementAt(i).id_role;
                            data.start_date  = providerList.ElementAt(i).start_date;
                            dataList.Add(data);
                        }
                        return(dataList);
                    }
                }
                catch
                {
                    dataList = null;
                    return(dataList);
                }
            }
        }