- if (User.Count != 0 || Email.Count != 0)
- {
- Session["EmailErrorMessage"] = "Username or Email already exists";
- }
-
- else if (User != null && UserMail != null && Designation != 5)
- {
- var employee = new Employees()
- {
- EmployeeID = UserName,
- Password = encerptd,
- Email = UserMail,
- FirstName = UserFirstName,
- LastName = UserLastName,
- Role = (int)Helpers.GlobalsVariables.Role.Entry,
- IsActive = true,
- CreatedDate = DateTime.Now,
- CreatedBy = 1,
- ModifiedBy = 1,
- Manager = Manager,
- ModifiedDate = DateTime.Now,
- Designation = UserDesignation
- };
- int employeeID = _employees.InsertAndReturnPk(employee);
- Session["successMessage"] = "User has been Created Successfully";
- }
- else
- {
- var employee = new Employees()
- {
- EmployeeID = UserName,
- Password = encerptd,
- Email = UserMail,
- FirstName = UserFirstName,
- LastName = UserLastName,
- IsActive = true,
- Role = (int)Helpers.GlobalsVariables.Role.Admin,
- CreatedDate = DateTime.Now,
- CreatedBy = 1,
- ModifiedBy = 1,
- ModifiedDate = DateTime.Now,
- Designation = UserDesignation,
- Manager = null
- };
- int employeeID = _employees.InsertAndReturnPk(employee);
- Session["successMessage"] = "User has been Created Successfully";
- }
instead of creating class object multiple time in single method.Can i create class object only single time and using multiple time in single method.
Here is my code in conditon.I need to create class object for single time and use in if conditon and else condition with different parameter it that possible to do to resude my code of lines .Please help me