public Employee(int id, User userId, Role roleId, Department departmentId, string name, int designation,
     string email, DateTime createdDate, Employee createdBy, int status)
 {
     this.Id = id;
     this.User = userId;
     this.Role = roleId;
     this.Department = departmentId;
     this.Name = name;
     this.Designation = designation;
     this.Email = email;
     this.CreatedDate = createdDate;
     this.CreatedBy = createdBy;
     this.Status = status;
 }
        public static Constants.DB_STATUS Assign(IEmployeeBroker employeeBroker, int employeeId, Constants.EMPLOYEE_ROLE role)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            Employee employee = new Employee();
            employee.Id = employeeId;
            employee = employeeBroker.GetEmployee(employee);

            Role assignRole = new Role();
            assignRole.Id = Converter.objToInt(role);
            assignRole = employeeBroker.GetRole(assignRole);
            employee.Role = assignRole;

            status = employeeBroker.Update(employee);

            return status;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Roles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRoles(Role role)
 {
     base.AddObject("Roles", role);
 }
 /// <summary>
 /// Create a new Role object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Role CreateRole(global::System.Int32 id, global::System.String name, global::System.DateTime createdDate, global::System.Int32 status)
 {
     Role role = new Role();
     role.Id = id;
     role.Name = name;
     role.CreatedDate = createdDate;
     role.Status = status;
     return role;
 }
        /// <summary>
        /// Update the role data to the role table
        /// </summary>
        /// <param name="role"></param>
        /// <returns>
        /// Returns DB_STATUS
        /// </returns>
        public Constants.DB_STATUS Update(Role role)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {
                roleObj = inventory.Roles.Where(rObj => rObj.Id == role.Id).First();
                Employee createdBy = inventory.Employees.Where(e => e.Id == role.CreatedBy.Id).First();
                if (roleObj != null)
                {
                    roleObj.Id = role.Id;
                    roleObj.Name = role.Name;
                    roleObj.CreatedDate = role.CreatedDate;
                    roleObj.CreatedBy = createdBy;
                    inventory.SaveChanges();
                    status = Constants.DB_STATUS.SUCCESSFULL;
                }
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }
        /// <summary>
        /// Insert the role data to the role table
        /// </summary>
        /// <param name="newRole"></param>
        /// <returns>
        /// Return DB_STATUS
        /// </returns>
        public Constants.DB_STATUS Insert(Role newRole)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {
                inventory.AddToRoles(newRole);
                inventory.SaveChanges();
                status = Constants.DB_STATUS.SUCCESSFULL;
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }

            return status;
        }
 /// <summary>
 /// Get the role of Role table
 /// </summary>
 /// <param name="role"></param>
 /// <returns>
 /// Return role data
 /// </returns>
 public Role GetRole(Role role)
 {
     try
     {
         roleObj = inventory.Roles.Where(rObj => rObj.Id == role.Id).First();
     }
     catch (Exception e)
     {
         roleObj = null;
     }
         return roleObj;
 }
        /// <summary>
        /// Logically delete to the status of role table
        /// </summary>
        /// <param name="role"></param>
        /// <returns>
        /// Returns DB_STATUS
        /// </returns>
        public Constants.DB_STATUS Delete(Role role)
        {
            Constants.DB_STATUS status = Constants.DB_STATUS.UNKNOWN;

            try
            {
                roleObj = inventory.Roles.Where(rObj => rObj.Id == role.Id).First();
                if (roleObj != null)
                {
                    userObj.Status = 2;
                    inventory.SaveChanges();
                    status = Constants.DB_STATUS.SUCCESSFULL;
                }
            }
            catch (Exception e)
            {
                status = Constants.DB_STATUS.FAILED;
            }
            return status;
        }