Ejemplo n.º 1
0
        public IHttpActionResult AssignRepresentative(CustomDeptEmployee customDeptEmployee)
        {
            DeptUser newRep     = db.DeptUsers.SingleOrDefault(d => d.DeptEmployeeID == customDeptEmployee.DeptEmployeeID);
            DeptUser currentRep = db.DeptUsers.SingleOrDefault(d => d.Role == DepartmentRole.REPRESENTATIVE &&
                                                               d.DeptEmployee.DepartmentID == customDeptEmployee.DepartmentID);

            currentRep.Role = DepartmentRole.EMPLOYEE;
            newRep.Role     = DepartmentRole.REPRESENTATIVE;
            db.SaveChanges();
            return(Ok());
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetCurrentRep(int id)
        {
            DeptUser           rep      = db.DeptUsers.SingleOrDefault(d => d.DeptEmployee.DepartmentID == id && d.Role == DepartmentRole.REPRESENTATIVE);
            CustomDeptEmployee employee = new CustomDeptEmployee
            {
                DepartmentID     = id,
                DeptEmployeeName = rep.DeptEmployee.ToString(),
                Email            = rep.DeptEmployee.Email,
                Phone            = rep.DeptEmployee.Phone
            };

            return(Ok(employee));
        }