public JsonResult ReadEmployeeByRole() { List<Employee> list = new List<Employee>(); try { list = new UserData().GetEmployeesByRole((int)Enums.Role.Doctor); } catch (Exception ex) { } return Json(list, JsonRequestBehavior.AllowGet); }
public ActionResult ReadRoles([DataSourceRequest] DataSourceRequest request) { List<Role> list = new List<Role>(); try { list = new UserData().GetRoles(); } catch (Exception ex) { } return Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet); }
public static void PopulateEmployees(RadDropDownList ddl, Roles role) { try { var employees = new UserData().GetEmployeesByRole((int)role).Select(c => new { EmployeeId = c.EmployeeId, EmployeeName = c.FirstName + " " + c.LastName}).ToList(); employees.Insert(0, new { EmployeeId = 0, EmployeeName = "Select" }); ddl.DataSource = employees; ddl.ValueMember = "EmployeeId"; ddl.DisplayMember = "EmployeeName"; } catch (Exception x) { FileLogger.LogError(x); } }
public JsonResult Authenticate(Employee employee) { try { string key = Keys.EncryptionKey; employee.Password = Encryption.Encrypt(key, employee.Password); employee = new UserData().Authenticate(employee); if (employee.RoleId > 0) { Session["userid"] = employee.UserId; Session["email"] = employee.EmailId; Session["role"] = employee.RoleId; Session["employeename"] = employee.FirstName + " " + employee.LastName; Session["employeid"] = employee.EmployeeId; FormsAuthentication.SetAuthCookie(employee.UserId, true); } } catch { } return Json(employee, JsonRequestBehavior.AllowGet); }
private void LoginButton_Click(object sender, EventArgs e) { try { Employee employee = new Employee(); employee.UserId = UserText.Text.Trim(); employee.Password = Encryption.Encrypt(Resources.EncryptionKey, PasswordText.Text.Trim()); employee = new UserData().Authenticate(employee); if(employee.RoleId > 0) { Error.Text = ""; this.applicationsGroup.Enabled = true; this.practiceManagementGroup.Enabled = true; this.settingsGroup.Enabled = true; this.LoginPanel.Visible = false; this.FooterPanel.Visible = true; this.UserLabel.Text = employee.FirstName + " " + employee.LastName; } else { Error.Text = "Login failed !!"; } } catch (Exception x) { Error.Text = "Login failed !!"; } }