public ActionResult Create(UserModel model) { try { var currentUserId = UserContext.GetCurrentUser().UserID; var info = UserRepository.GetInfo(model.UserInfo.UserName); if (info == null) { var user = new UserInfo { CreatedBy = currentUserId, ChangedBy = currentUserId, Email = model.UserInfo.Email, Mobile = model.UserInfo.Mobile, UserName = model.UserInfo.UserName, FullName = model.UserInfo.FullName, Password = model.UserInfo.Password, StationId = model.UserInfo.StationId, Description = model.UserInfo.Description, IsCollector = model.UserInfo.IsCollector, IsSuperAdmin = model.UserInfo.IsSuperAdmin, IsConsultant = model.UserInfo.IsConsultant, IsCollaborator = model.UserInfo.IsCollaborator, }; var groupIds = new List<int>(); // IsCollaborator if (user.IsCollaborator) { if (model.PostedGroupCollaboratorType != null && model.PostedGroupCollaboratorType.Id.Any()) user.GroupCollaboratorType = model.PostedGroupCollaboratorType.Id.First(); if (model.PostedGroupCollaborator != null) groupIds.AddRange(model.PostedGroupCollaborator.Id); user.NormsCollaborator = model.UserInfo.NormsCollaborator; } // IsConsultant if (user.IsConsultant) { if (model.PostedGroupConsultantType != null && model.PostedGroupConsultantType.Id.Any()) user.GroupConsultantType = model.PostedGroupConsultantType.Id.First(); if (model.PostedGroupConsultant != null) groupIds.AddRange(model.PostedGroupConsultant.Id); user.NormsConsultant = model.UserInfo.NormsConsultant; } // RoleIds var roleIds = model.PostedRole.Id.ToList(); // BranchIds var branchIds = model.PostedBranch.Id.ToList(); // Inser User UserRepository.Insert(string.Join(",", roleIds), string.Join(",", groupIds), string.Join(",", branchIds), user); StoreData.ReloadData<UserInfo>(); ViewBag.Message = "Tạo mới người dùng thành công"; return RedirectToAction("Edit", new { id = user.UserID }); } ViewBag.Message = "Tên đăng nhập đã tồn tại, vui lòng chọn tên đăng nhập khác"; } catch { ViewBag.Message = "Cập nhật người dùng không thành công"; } return Create(); }
public static void Update(string roleIds, string groupIds, string branchIds, UserInfo info) { DataProvider.Instance().User_Update(info.UserID, roleIds, groupIds, branchIds, info.UserName, info.Password, info.FullName, info.Email, info.Mobile, info.Description, info.Status, info.ChangedBy, info.StationId, info.IsSuperAdmin, info.IsCollector, info.IsCollaborator, info.GroupCollaboratorType, info.NormsCollaborator, info.IsConsultant, info.GroupConsultantType, info.NormsConsultant); }
public static void UpdateNorms(UserInfo info) { DataProvider.Instance().User_Update_Norms(info.UserID, info.ChangedBy, info.NormsCollaborator, info.NormsConsultant); }
public static void Insert(string roleIds, string groupIds, string branchIds, UserInfo info) { info.Password = SecurityHelper.GetMD5Hash(info.Password); info.UserID = DataProvider.Instance().User_Insert(roleIds, groupIds, branchIds, info.UserName, info.Password, info.FullName, info.Email, info.Mobile, info.Description, info.Status, info.CreatedBy, info.StationId, info.IsSuperAdmin, info.IsCollector, info.IsCollaborator, info.GroupCollaboratorType, info.NormsCollaborator, info.IsConsultant, info.GroupConsultantType, info.NormsConsultant); }