private void Logon(string username, string password) { try { using (VACP4DBContext db = new VACP4DBContext()) { var user = db.UserMaster.Where(x => x.UserId == username && x.Password == password).FirstOrDefault(); if (user != null) { currentUser = user; FrmImport frm = new FrmImport(); frm.Show(); this.Hide(); } else { MessageBox.Show("Invalid username or password!", "Error", MessageBoxButtons.OK); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK); } }
public StatusDTO <UserMasterDTO> Delete(UserMasterDTO user) { StatusDTO <UserMasterDTO> status = null; try { if (user != null && user.UserMasterId != 0) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.Connection = dbSvc.GetConnection() as MySqlConnection; command.CommandText = "UPDATE usermaster SET Active=0 WHERE UserMasterId=@UserMasterId"; command.Parameters.Add("@UserMasterId", MySqlDbType.Int32).Value = user.UserMasterId; if (command.ExecuteNonQuery() > 0) { status = new StatusDTO <UserMasterDTO>(); status.IsSuccess = true; } } } } catch (Exception ex) { _logger.Log(ex); throw ex; } return(status); }
public string CapNhatTaiKhoan(UserMasterDTO userMaster) { string status = "ok"; try { var tk = models.UserMasters.Where(s => s.ID == userMaster.ID).FirstOrDefault(); if (tk != null) { tk.UserName = userMaster.UserName.Trim(); tk.UserPassword = userMaster.UserPassword; tk.UserRoles = userMaster.UserRoles; tk.FullName = userMaster.FullName; tk.PhoneNumber = userMaster.PhoneNumber; tk.UserEmailID = userMaster.UserEmailID; tk.IsDelete = userMaster.IsDelete; tk.MaDoan = userMaster.MaDoan; tk.UserID = userMaster.UserID; models.SaveChanges(); } } catch (Exception) { return(status = "Lỗi không thể lưu tài khoản!"); } return(status); }
public ActionResult Login(UserMasterDTO data) { List <EntitlementDTO> lstEntitleMent = new List <EntitlementDTO>(); List <ActionDTO> lstAction = new List <ActionDTO>(); string unencryptedPass = data.Password; string pass = encrypt.encryption(data.Password); data.Password = pass; StatusDTO <UserMasterDTO> status = _userSvc.Login(data, out lstEntitleMent, out lstAction); if (status.IsSuccess) { if (data.RememberMe) { HttpCookie cookie = new HttpCookie("userDetails"); cookie["uid"] = data.UserName; cookie["pwd"] = unencryptedPass; cookie.Expires = DateTime.Now + new TimeSpan(1, 0, 0, 0); if (Request.Cookies["userDetails"] != null) { Response.Cookies.Set(cookie); } else { Response.Cookies.Add(cookie); } } else { Response.Cookies.Remove("userDetails"); } SessionDTO session = new SessionDTO(); session.UserMasterId = status.ReturnObj.UserMasterId; session.UserName = status.ReturnObj.UserName; session.FName = status.ReturnObj.FName; session.MName = status.ReturnObj.MName; session.LName = status.ReturnObj.LName; session.ActionList = lstAction; session.EntitleMentList = lstEntitleMent; _sessionSvc.SetUserSession(session); SessionDTO sessionRet = _sessionSvc.GetUserSession(); } else { data.LoginFailedMsg = status.FailureReason; return(View(data)); } return(RedirectToAction("Landing", "Login", new { area = "Login" }));; }
public int RegisterUser(UserMasterDTO user) { UserMaster U = mapper.Map <UserMaster>(user); U.UserID = UserRepository.RegisterUser(U); if (U.UserID > 0) { UserRepository.AddUserRole(U, user.IsAdmin); } return(U.UserID); }
public SelectList getUserDropDown() { List <UserMasterDTO> lstUserMaster = _ddlRepo.GetAllActiveUsers(); UserMasterDTO umDTO = new UserMasterDTO(); umDTO.UserMasterId = -1; umDTO.FName = string.Empty; lstUserMaster.Insert(0, umDTO); return(new SelectList(lstUserMaster, "UserMasterId", "FName")); }
public ActionResult DeleteUser(UserMasterDTO user) { //UserMasterDTO user = null; if (user.UserMasterId != 0) { //user = new UserMasterDTO(); //user.UserMasterId = id; StatusDTO <UserMasterDTO> status = _userSvc.Delete(user); if (status != null && status.IsSuccess) { } } return(Json(new { message = "success", status = "true" }, JsonRequestBehavior.AllowGet)); }
public UserMasterDTO TaiKhoanDuocLayMau() { UserMasterDTO userMaster = new UserMasterDTO(); userMaster.ID = 132; userMaster.UserName = "******"; userMaster.UserPassword = "******"; userMaster.UserRoles = "nv"; userMaster.UserEmailID = "*****@*****.**"; userMaster.FullName = "Nguyễn Đức Tuấn Anh"; userMaster.PhoneNumber = "058059900"; userMaster.UserID = 0; userMaster.MaDoan = ""; userMaster.IsDelete = false; return(userMaster); }
public List <UserMasterDTO> GetAllActiveUsers() { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "select UserMasterId,FName,MName,LName,UserName from usermaster where Active=1"; command.Connection = dbSvc.GetConnection() as MySqlConnection; _dtData = new DataTable(); MySqlDataAdapter msDa = new MySqlDataAdapter(command); msDa.Fill(_dtData); List <UserMasterDTO> lstUserMaster = new List <UserMasterDTO>(); if (_dtData != null && _dtData.Rows.Count > 0) { UserMasterDTO userMasterDTO = null; foreach (DataRow dr in _dtData.Rows) { userMasterDTO = new UserMasterDTO(); if (!string.IsNullOrEmpty(dr["FName"].ToString())) { userMasterDTO.FName = dr["FName"].ToString(); } if (!string.IsNullOrEmpty(dr["MName"].ToString())) { userMasterDTO.FName = userMasterDTO.FName + " " + dr["MName"].ToString(); } if (!string.IsNullOrEmpty(dr["LName"].ToString())) { userMasterDTO.FName = userMasterDTO.FName + " " + dr["LName"].ToString(); } userMasterDTO.FName = userMasterDTO.FName + " - " + dr["UserName"].ToString(); userMasterDTO.UserMasterId = (int)dr["UserMasterId"]; lstUserMaster.Add(userMasterDTO); } } return(lstUserMaster); } catch (Exception exp) { throw exp; } } }
public JsonResponse <int> AddNewStudent(UserMasterDTO user) { JsonResponse <int> response = new JsonResponse <int>(); UserMasterDTO User = new UserMasterDTO(); if (!string.IsNullOrEmpty(user.Email)) { User = UserBusinessInstance.GetUserByEmail(user.Email); } if (User == null) { try { user.UserStatus = 1; // (int)AspectEnums.AccountStatus.Pending; user.CreatedDate = DateTime.Now; response.SingleResult = StudentBusinessInstance.SubmitNewStudent(user); response.StatusCode = response.SingleResult > 0 ? "200" : "500"; response.IsSuccess = response.SingleResult > 0 ? true : false; response.Message = "User successfully submitted."; } catch (FormattedDbEntityValidationException ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = string.Format(Messages.Exception, ex.Message, ex.InnerException, ex.StackTrace); } catch (Exception ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = string.Format(Messages.Exception, ex.Message, ex.InnerException, ex.StackTrace); } } else { response.SingleResult = 0; response.IsSuccess = false; response.StatusCode = "200"; response.Message = string.Format("User with email address {0} already exists. Try again.", user.Email); } return(response); }
public ActionResult Login() { UserMasterDTO userDto = new UserMasterDTO(); if (Request.Cookies["userDetails"] != null) { var userId = Request.Cookies["userDetails"]["uid"]; var pwd = Request.Cookies["userDetails"]["pwd"]; if (!string.IsNullOrEmpty(userId) && pwd != null && !string.IsNullOrEmpty(pwd)) { //userDto = new UserMasterDTO(); userDto.RememberMe = true; userDto.UserName = userId; userDto.Password = pwd; return(View(userDto)); } } return(View(userDto)); }
public IHttpActionResult ThemTaiKhoan([FromBody] dynamic dynamic) { UserMasterDTO tk = JsonConvert.DeserializeObject <UserMasterDTO>(dynamic.ToString()); if (tk == null) { return(BadRequest("Thêm tài khoản thất bại!")); } using (QuanLyBusiness quanLy = new QuanLyBusiness()) { if (quanLy.ThemTaiKhoan(tk)) { return(Ok("Thêm tài khoản thành công!")); } else { return(BadRequest("Thêm tài khoản thất bại!")); } } }
public IHttpActionResult CapNhatTaiKhoan([FromBody] dynamic dynamic) { UserMasterDTO tk = JsonConvert.DeserializeObject <UserMasterDTO>(dynamic.ToString()); if (tk == null) { return(BadRequest("Cập nhật thất bại!")); } using (QuanLyBusiness quanLy = new QuanLyBusiness()) { string result = quanLy.CapNhatTaiKhoan(tk); if (result.Equals("ok")) { return(Ok("Cập nhật tài khoản thành công!")); } else { return(BadRequest(result)); } } }
public JsonResponse <UserMasterDTO> UpdateUserMasterDTO(UserMasterDTO user) { JsonResponse <UserMasterDTO> response = new JsonResponse <UserMasterDTO>(); try { var User = UserBusinessInstance.GetUserByEmail(user.Email); if (User == null) { response.SingleResult = user; response.StatusCode = "200"; response.Message = "User does not exist in our system."; return(response); } User.FirstName = user.FirstName; User.LastName = user.LastName; User.ImagePath = user.ImagePath; User.Email = user.Email; User.Mobile = user.Mobile; User.Password = user.Password; User.Address = user.Address; User.City = user.City; User.State = user.State; User.UserCode = user.Email; User.IsDeleted = user.IsDeleted; user.UpdatedDate = DateTime.Now; response.IsSuccess = UserBusinessInstance.RegisterUser(user) > 0 ? true : false; response.SingleResult = user; response.StatusCode = "200"; } catch (Exception ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = ex.Message; } return(response); }
public JsonResponse <int> RegisterUserMasterDTO(UserMasterDTO user) { JsonResponse <int> response = new JsonResponse <int>(); var User = UserBusinessInstance.GetUserByEmail(user.Email); if (User == null) { try { user.UserStatus = (int)AspectEnums.AccountStatus.Pending; response.SingleResult = UserBusinessInstance.RegisterUser(user); response.StatusCode = response.SingleResult > 0 ? "200" : "500"; response.IsSuccess = response.SingleResult > 0 ? true : false; response.Message = "User successfully submitted."; } catch (FormattedDbEntityValidationException ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = string.Format(Messages.Exception, ex.Message, ex.InnerException, ex.StackTrace); } catch (Exception ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = string.Format(Messages.Exception, ex.Message, ex.InnerException, ex.StackTrace); } } else { response.SingleResult = 0; response.IsSuccess = false; response.StatusCode = "200"; response.Message = string.Format("User with email address {0} already exists. Try again.", user.Email); } return(response); }
public bool ThemTaiKhoan(UserMasterDTO userMaster) { UserMaster tk = new UserMaster(); if (CheckUserMaster(userMaster.UserName)) { tk.UserName = userMaster.UserName; tk.UserPassword = userMaster.UserPassword; tk.UserRoles = userMaster.UserRoles; tk.FullName = userMaster.FullName; tk.PhoneNumber = userMaster.PhoneNumber; tk.UserEmailID = userMaster.UserEmailID; tk.IsDelete = userMaster.IsDelete; tk.MaDoan = userMaster.MaDoan; tk.UserID = userMaster.UserID; models.UserMasters.Add(tk); models.SaveChanges(); return(true); } else { return(false); } }
public StatusDTO <UserMasterDTO> Update(UserMasterDTO data) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "update_UserDetails"; command.CommandType = CommandType.StoredProcedure; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@UserMasterId1", MySqlDbType.String).Value = data.UserMasterId; command.Parameters.Add("@FName", MySqlDbType.String).Value = data.FName; command.Parameters.Add("@MName", MySqlDbType.String).Value = data.MName; command.Parameters.Add("@LName", MySqlDbType.String).Value = data.LName; command.Parameters.Add("@Gender", MySqlDbType.String).Value = data.Gender; command.Parameters.Add("@Image", MySqlDbType.String).Value = data.Image; command.Parameters.Add("@DOB", MySqlDbType.DateTime).Value = data.DOB; command.Parameters.Add("@EmailId", MySqlDbType.String).Value = data.EmailId; command.Parameters.Add("@ResidentialAddress", MySqlDbType.String).Value = data.ResidentialAddress; command.Parameters.Add("@PermanentAddress", MySqlDbType.String).Value = data.PermanentAddress; command.Parameters.Add("@ContactNo", MySqlDbType.String).Value = data.ContactNo; command.Parameters.Add("@AltContactNo", MySqlDbType.String).Value = data.AltContactNo; command.Parameters.Add("@BloodGroup", MySqlDbType.String).Value = data.BloodGroup; command.Parameters.Add("@UserName", MySqlDbType.String).Value = data.UserName; command.Parameters.Add("@UserPassword", MySqlDbType.String).Value = data.Password; //command.Parameters.Add("@RoleId", MySqlDbType.Int32).Value = data.Role.RoleId; command.Parameters.Add("@LocationId", MySqlDbType.Int32).Value = data.Location.LocationId; command.Parameters.Add("@StaffEmployeeId", MySqlDbType.String).Value = data.Employee.StaffEmployeeId; command.Parameters.Add("@EducationQualification", MySqlDbType.String).Value = data.Employee.EducationalQualification; command.Parameters.Add("@DateOfJoining", MySqlDbType.DateTime).Value = data.Employee.DateOfJoining; command.Parameters.Add("@DepartmentId", MySqlDbType.Int32).Value = data.Employee.Department.DepartmentId; if (data.Employee.Department.DepartmentId == 1) { command.Parameters.Add("@ClassTypeId", MySqlDbType.Int32).Value = data.Employee.ClassType.ClassTypeId; //if (data.Employee.ClassType.ClassTypeId > 2) //{ // command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = data.Employee.Subject.SubjectId; //} //else //{ // command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = DBNull.Value; //} } else { command.Parameters.Add("@ClassTypeId", MySqlDbType.Int32).Value = DBNull.Value; //command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = DBNull.Value; } command.Parameters.Add("@DesignationId", MySqlDbType.Int32).Value = data.Employee.Designation.DesignationId; command.ExecuteNonQuery(); StatusDTO <UserMasterDTO> status = new StatusDTO <UserMasterDTO>(); status.IsSuccess = true; return(status); } catch (Exception exp) { throw exp; } } }
public StatusDTO <UserMasterDTO> Login(UserMasterDTO data, out List <EntitlementDTO> roleList, out List <ActionDTO> actionList) { StatusDTO <UserMasterDTO> status = new StatusDTO <UserMasterDTO>(); roleList = null; actionList = null; using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "UserLogin"; command.CommandType = CommandType.StoredProcedure; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@UserName", MySqlDbType.String).Value = data.UserName; command.Parameters.Add("@UserPassword", MySqlDbType.String).Value = data.Password; MySqlParameter error = new MySqlParameter("@ErrorMsg", MySqlDbType.VarChar); error.Direction = ParameterDirection.Output; command.Parameters.Add(error); MySqlDataAdapter rdr = new MySqlDataAdapter(command); _dsData = new DataSet(); rdr.Fill(_dsData); List <EntitlementDTO> entitlementList = new List <EntitlementDTO>(); List <ActionDTO> useractionList = new List <ActionDTO>(); UserMasterDTO userMaster = new UserMasterDTO(); if (_dsData != null && _dsData.Tables.Count == 3) { if (_dsData.Tables[0].Rows.Count > 0) { userMaster.UserMasterId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["UserMasterId"]); userMaster.UserName = _dsData.Tables[0].Rows[0]["UserName"].ToString(); userMaster.FName = _dsData.Tables[0].Rows[0]["FName"].ToString(); userMaster.MName = _dsData.Tables[0].Rows[0]["MName"].ToString(); userMaster.LName = _dsData.Tables[0].Rows[0]["LName"].ToString(); } if (_dsData.Tables[1].Rows.Count > 0) { EntitlementDTO userEntitle = new EntitlementDTO(); for (int i = 0; i < _dsData.Tables[1].Rows.Count; i++) { userEntitle.UserRoleId = Convert.ToInt32(_dsData.Tables[1].Rows[i]["UserRoleId"]); userEntitle.RoleName = _dsData.Tables[1].Rows[i]["RoleName"].ToString(); entitlementList.Add(userEntitle); } roleList = entitlementList; } if (_dsData.Tables[2].Rows.Count > 0) { ActionDTO useractionDTO = null; for (int i = 0; i < _dsData.Tables[2].Rows.Count; i++) { useractionDTO = new ActionDTO(); useractionDTO.ActionName = _dsData.Tables[2].Rows[i]["ActionName"].ToString(); useractionDTO.ActionLink = _dsData.Tables[2].Rows[i]["ActionLink"].ToString(); useractionDTO.IsChildAction = Convert.ToBoolean(_dsData.Tables[2].Rows[i]["IsChildAction"]); useractionDTO.MenuText = _dsData.Tables[2].Rows[i]["MenuText"].ToString(); useractionDTO.DisabledControlId = _dsData.Tables[2].Rows[i]["DisabledControlId"].ToString(); useractionDTO.HiddenControlId = _dsData.Tables[2].Rows[i]["HiddenControlId"].ToString(); useractionDTO.GroupName = _dsData.Tables[2].Rows[i]["GroupName"].ToString(); useractionDTO.MenuImage = _dsData.Tables[2].Rows[i]["MenuImage"].ToString(); if (useractionDTO.IsChildAction || !string.IsNullOrEmpty(_dsData.Tables[2].Rows[i]["ParentActionId"].ToString())) { useractionDTO.ParentAction = new ActionDTO(); useractionDTO.ParentAction.RowId = Convert.ToInt32(_dsData.Tables[2].Rows[i]["ParentActionId"]); useractionDTO.ParentAction.ActionLink = _dsData.Tables[2].Select("ActionId=" + useractionDTO.ParentAction.RowId)[0]["ActionLink"].ToString(); } useractionList.Add(useractionDTO); } actionList = useractionList; } status.IsException = false; status.IsSuccess = true; status.ReturnObj = userMaster; } else { status.IsSuccess = false; status.FailureReason = error.Value.ToString(); } return(status); } catch (Exception exp) { throw exp; } } }
public bool UpdateStudentInfo(UserMasterDTO student) { throw new NotImplementedException(); }
public int SubmitNewStudent(UserMasterDTO student) { UserMaster U = mapper.Map <UserMaster>(student); return(StudentRepository.SubmitNewStudent(U)); }
public StatusDTO <List <UserMasterDTO> > Select(UserMasterDTO data) { StatusDTO <List <UserMasterDTO> > userList = new StatusDTO <List <UserMasterDTO> >(); string whereClause = null; string selectClause = null; DataSet dsUserLst = null; using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); //openning the connection MySqlCommand command = new MySqlCommand(); // creating my sql command for queries command.Connection = dbSvc.GetConnection() as MySqlConnection; selectClause = "SELECT users.UserMasterId,users.FName,users.MName,users.LName,users.Gender,users.EmailId,users.ResidentialAddress,users.PermanentAddress," + "users.ContactNo,users.AltContactNo,users.BloodGroup,r.RoleDescription" + " FROM usermaster users" + " INNER JOIN roles r ON users.RoleId = r.RoleId AND users.RoleId>1"; whereClause = " WHERE users.Active = 1"; if (data != null) { //Name Search if (!string.IsNullOrEmpty(data.FName)) { data.FName = data.FName + "%"; whereClause = whereClause + " AND users.FName LIKE @FName"; command.Parameters.Add("@FName", MySqlDbType.String).Value = data.FName; } if (!string.IsNullOrEmpty(data.MName)) { data.MName = data.MName + "%"; whereClause = whereClause + " AND users.MName LIKE @MName "; command.Parameters.Add("@MName", MySqlDbType.String).Value = data.MName; } if (!string.IsNullOrEmpty(data.LName)) { data.LName = data.LName + "%"; whereClause = whereClause + " AND users.LName LIKE @LName "; command.Parameters.Add("@LName", MySqlDbType.String).Value = data.LName; } //Gender Search if (!string.IsNullOrEmpty(data.Gender) && !string.Equals(data.Gender, "-1")) { whereClause = whereClause + " AND users.Gender=@Gender "; command.Parameters.Add("@Gender", MySqlDbType.String).Value = data.Gender; } // Role Search if (!string.IsNullOrEmpty(data.Role.RoleDescription)) { whereClause = whereClause + " AND r.RoleDescription=@RoleDescription"; command.Parameters.Add("@RoleDescription", MySqlDbType.String).Value = data.Role.RoleDescription; } //BloodGroup Search if (!string.IsNullOrEmpty(data.BloodGroup)) { whereClause = whereClause + " AND users.BloodGroup=@BloodGroup"; command.Parameters.Add("@BloodGroup", MySqlDbType.String).Value = data.BloodGroup; } } command.CommandText = selectClause + whereClause; MySqlDataAdapter da = new MySqlDataAdapter(command); dsUserLst = new DataSet(); da.Fill(dsUserLst); if (dsUserLst != null && dsUserLst.Tables.Count > 0) { userList.ReturnObj = new List <UserMasterDTO>(); for (int i = 0; i < dsUserLst.Tables[0].Rows.Count; i++) { UserMasterDTO user = new UserMasterDTO(); user.UserMasterId = Convert.ToInt32(dsUserLst.Tables[0].Rows[i]["UserMasterId"]); user.FName = dsUserLst.Tables[0].Rows[i]["FName"].ToString(); user.MName = dsUserLst.Tables[0].Rows[i]["MName"].ToString(); user.LName = dsUserLst.Tables[0].Rows[i]["LName"].ToString(); user.Gender = dsUserLst.Tables[0].Rows[i]["Gender"].ToString(); user.EmailId = dsUserLst.Tables[0].Rows[i]["EmailId"].ToString(); user.ResidentialAddress = dsUserLst.Tables[0].Rows[i]["ResidentialAddress"].ToString(); user.PermanentAddress = dsUserLst.Tables[0].Rows[i]["PermanentAddress"].ToString(); user.ContactNo = dsUserLst.Tables[0].Rows[i]["ContactNo"].ToString(); user.AltContactNo = dsUserLst.Tables[0].Rows[i]["AltContactNo"].ToString(); user.BloodGroup = dsUserLst.Tables[0].Rows[i]["BloodGroup"].ToString(); user.Role = new RoleDTO(); user.Role.RoleDescription = dsUserLst.Tables[0].Rows[i]["RoleDescription"].ToString(); userList.ReturnObj.Add(user); userList.IsSuccess = true; } } } catch (Exception ex) { _logger.Log(ex); userList.IsSuccess = false; userList.IsException = true; userList.ReturnObj = null; userList.ExceptionMessage = ex.Message; userList.StackTrace = ex.StackTrace; } } return(userList); }
public ActionResult Search(UserVM userView, string Command) { UserVM uView = null; UserMasterDTO user = null; if (string.Equals(Command, "Add")) { return(RedirectToAction("Register", "Login", new { area = "Login" })); } if (userView != null) { //Fetch the StandardSection List userView.GenderList = _uiddlRepo.getGenderDropDown(); user = new UserMasterDTO(); // Search for FName LName and MName user.FName = userView.FName; user.MName = userView.MName; user.LName = userView.LName; // Search for Gender user.Gender = userView.Gender; // Search for Role user.Role = new RoleDTO(); user.Role.RoleDescription = userView.Role.RoleDescription; // Search for BloodGroup user.BloodGroup = userView.BloodGroup; StatusDTO <List <UserMasterDTO> > status = _userSvc.Select(user); if (status != null && status.ReturnObj != null && status.ReturnObj.Count > 0) { // userView = new UserVM(); //userView.IsSearchSuccessful = true;// Grid is displayed with records uView = new UserVM(); // Instantiating Student View model uView.UserList = new List <UserVM>(); // instantiating list of Students //Fetch the Gender List uView.GenderList = _uiddlRepo.getGenderDropDown(); if (status.IsSuccess && !status.IsException) { UserVM searchItem = null; foreach (UserMasterDTO u in status.ReturnObj) { if (u != null) { searchItem = new UserVM(); // instantiating each user searchItem.UserMasterId = u.UserMasterId; searchItem.FName = u.FName; searchItem.MName = u.MName; searchItem.LName = u.LName; //forming the Name searchItem.Name = searchItem.FName; if (!string.IsNullOrEmpty(searchItem.MName)) { searchItem.Name = searchItem.Name + " " + searchItem.MName; } searchItem.Name = searchItem.Name + " " + searchItem.LName; searchItem.Gender = u.Gender; searchItem.EmailId = u.EmailId; searchItem.ResidentialAddress = u.ResidentialAddress; searchItem.PermanentAddress = u.PermanentAddress; searchItem.ContactNo = u.ContactNo; searchItem.AltContactNo = u.AltContactNo; searchItem.BloodGroup = u.BloodGroup; searchItem.Role = new RoleDTO(); searchItem.Role.RoleDescription = u.Role.RoleDescription; uView.UserList.Add(searchItem); uView.IsSearchSuccessful = true; } } } } else { userView.IsSearchSuccessful = false; uView = userView; } } return(View(uView)); }
public StatusDTO <UserMasterDTO> Select(int rowId) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "get_UserDetails"; command.CommandType = CommandType.StoredProcedure; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@UserMasterId1", MySqlDbType.Int32).Value = rowId; MySqlDataAdapter rdr = new MySqlDataAdapter(command); _dsData = new DataSet(); rdr.Fill(_dsData); StatusDTO <UserMasterDTO> status = new StatusDTO <UserMasterDTO>(); UserMasterDTO usermasterDTO = new UserMasterDTO(); if (_dsData != null && _dsData.Tables.Count > 0) { if (_dsData.Tables[0].Rows.Count > 0) { usermasterDTO.UserMasterId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["UserMasterId"]); usermasterDTO.Role = new RoleDTO(); usermasterDTO.Role.RoleId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["RoleId"]); usermasterDTO.Location = new LocationDTO(); usermasterDTO.Location.LocationId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["LocationId"]); usermasterDTO.FName = _dsData.Tables[0].Rows[0]["FName"].ToString(); usermasterDTO.MName = _dsData.Tables[0].Rows[0]["MName"].ToString(); usermasterDTO.LName = _dsData.Tables[0].Rows[0]["LName"].ToString(); usermasterDTO.Gender = _dsData.Tables[0].Rows[0]["Gender"].ToString(); usermasterDTO.Image = _dsData.Tables[0].Rows[0]["Image"].ToString(); if (!String.IsNullOrEmpty(_dsData.Tables[0].Rows[0]["DOB"].ToString())) { usermasterDTO.DOB = Convert.ToDateTime(_dsData.Tables[0].Rows[0]["DOB"]); } else { usermasterDTO.DOB = null; } usermasterDTO.EmailId = _dsData.Tables[0].Rows[0]["EmailId"].ToString(); usermasterDTO.ResidentialAddress = _dsData.Tables[0].Rows[0]["ResidentialAddress"].ToString(); usermasterDTO.PermanentAddress = _dsData.Tables[0].Rows[0]["PermanentAddress"].ToString(); usermasterDTO.ContactNo = _dsData.Tables[0].Rows[0]["ContactNo"].ToString(); usermasterDTO.AltContactNo = _dsData.Tables[0].Rows[0]["AltContactNo"].ToString(); usermasterDTO.BloodGroup = _dsData.Tables[0].Rows[0]["BloodGroup"].ToString(); usermasterDTO.Employee = new EmployeeDetailsDTO(); usermasterDTO.Employee.EmployeeId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["EmployeeId"]); usermasterDTO.Employee.EducationalQualification = _dsData.Tables[0].Rows[0]["EducationQualification"].ToString(); if (!String.IsNullOrEmpty(_dsData.Tables[0].Rows[0]["DateOfJoining"].ToString())) { usermasterDTO.Employee.DateOfJoining = Convert.ToDateTime(_dsData.Tables[0].Rows[0]["DateOfJoining"]); } else { usermasterDTO.Employee.DateOfJoining = null; } usermasterDTO.Employee.Department = new DepartmentDTO(); if (!string.IsNullOrEmpty(_dsData.Tables[0].Rows[0]["DepartmentId"].ToString())) { usermasterDTO.Employee.Department.DepartmentId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["DepartmentId"]); } usermasterDTO.Employee.StaffEmployeeId = _dsData.Tables[0].Rows[0]["StaffEmployeeId"].ToString(); usermasterDTO.Employee.Designation = new DesignationDTO(); if (!string.IsNullOrEmpty(_dsData.Tables[0].Rows[0]["DepartmentId"].ToString())) { usermasterDTO.Employee.Designation.DesignationId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["DepartmentId"]); } usermasterDTO.Employee.ClassType = new ClassTypeDTO(); //usermasterDTO.Employee.Subject = new SubjectDTO(); if (!string.IsNullOrEmpty(_dsData.Tables[0].Rows[0]["ClassTypeId"].ToString()) && Convert.ToInt32(_dsData.Tables[0].Rows[0]["ClassTypeId"]) > 0) { usermasterDTO.Employee.ClassType.ClassTypeId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["ClassTypeId"]); //if(Convert.ToInt32(_dsData.Tables[0].Rows[0]["SubjectId"]) > 0) //{ // usermasterDTO.Employee.Subject.SubjectId = Convert.ToInt32(_dsData.Tables[0].Rows[0]["SubjectId"]); //} } } } status.ReturnObj = usermasterDTO; return(status); } catch (Exception exp) { throw exp; } } }
public StatusDTO <UserMasterDTO> Insert(UserMasterDTO data) { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "ins_UserDetails"; command.CommandType = CommandType.StoredProcedure; command.Connection = dbSvc.GetConnection() as MySqlConnection; command.Parameters.Add("@UserMasterId1", MySqlDbType.String).Value = data.UserMasterId; command.Parameters.Add("@FName", MySqlDbType.String).Value = data.FName; command.Parameters.Add("@MName", MySqlDbType.String).Value = data.MName; command.Parameters.Add("@LName", MySqlDbType.String).Value = data.LName; command.Parameters.Add("@Gender", MySqlDbType.String).Value = data.Gender; command.Parameters.Add("@Image", MySqlDbType.String).Value = data.Image; command.Parameters.Add("@DOB", MySqlDbType.DateTime).Value = data.DOB; command.Parameters.Add("@EmailId", MySqlDbType.String).Value = data.EmailId; command.Parameters.Add("@ResidentialAddress", MySqlDbType.String).Value = data.ResidentialAddress; command.Parameters.Add("@PermanentAddress", MySqlDbType.String).Value = data.PermanentAddress; command.Parameters.Add("@ContactNo", MySqlDbType.String).Value = data.ContactNo; command.Parameters.Add("@AlContactNo", MySqlDbType.String).Value = data.AltContactNo; command.Parameters.Add("@BloodGroup", MySqlDbType.String).Value = data.BloodGroup; command.Parameters.Add("@UserName", MySqlDbType.String).Value = data.UserName; command.Parameters.Add("@UserPassword", MySqlDbType.String).Value = data.Password; //command.Parameters.Add("@RoleId", MySqlDbType.Int32).Value = data.Role.RoleId; command.Parameters.Add("@LocationId", MySqlDbType.Int32).Value = data.Location.LocationId; command.Parameters.Add("@StaffEmployeeId", MySqlDbType.String).Value = data.Employee.StaffEmployeeId; command.Parameters.Add("@EducationQualification", MySqlDbType.String).Value = data.Employee.EducationalQualification; command.Parameters.Add("@DateOfJoining", MySqlDbType.DateTime).Value = data.Employee.DateOfJoining; command.Parameters.Add("@DepartmentId", MySqlDbType.Int32).Value = data.Employee.Department.DepartmentId; if (data.Employee.Department.DepartmentId == 1 && data.Employee.ClassType.ClassTypeId > 0) { command.Parameters.Add("@ClassTypeId", MySqlDbType.Int32).Value = data.Employee.ClassType.ClassTypeId; //if(data.Employee.ClassType.ClassTypeId > 2) //{ // command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = data.Employee.Subject.SubjectId; //} //else //{ // command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = DBNull.Value; //} } else { command.Parameters.Add("@ClassTypeId", MySqlDbType.Int32).Value = DBNull.Value; //command.Parameters.Add("@SubjectId", MySqlDbType.Int32).Value = DBNull.Value; } command.Parameters.Add("@DesignationId", MySqlDbType.Int32).Value = data.Employee.Designation.DesignationId; MySqlDataReader rdr = command.ExecuteReader(CommandBehavior.CloseConnection); _dtData = new DataTable(); _dtData.Load(rdr); StatusDTO <UserMasterDTO> status = new StatusDTO <UserMasterDTO>(); if (_dtData.Rows.Count > 0 && !String.IsNullOrEmpty(_dtData.Rows[0]["Message"].ToString())) { status.IsSuccess = true; status.ReturnObj = new UserMasterDTO(); status.ReturnObj.UserMasterId = (int)_dtData.Rows[0]["Message"]; if (!String.IsNullOrEmpty(_dtData.Rows[0]["Message1"].ToString())) { status.ReturnObj.Employee = new EmployeeDetailsDTO(); status.ReturnObj.Employee.EmployeeId = (int)_dtData.Rows[0]["Message1"]; } } else { status.IsSuccess = false; status.FailureReason = "User Insertion Failed"; } return(status); } catch (Exception exp) { throw exp; } } }
public int UpdateUser(UserMasterDTO user) { UserMaster U = mapper.Map <UserMaster>(user); return(UserRepository.RegisterUser(U)); }