//for Group drp public UserGroupPOCO GetAllGroupsForDrp() { UserGroupBL bL = new UserGroupBL(); List <UserGroupPOCO> pocoList = new List <UserGroupPOCO>(); pocoList = bL.GetAllGroupsForDrp(); UserGroupPOCO pOCO = new UserGroupPOCO(); var list = new List <KeyValuePair <string, string> >(); foreach (UserGroupPOCO up in pocoList) { UserGroupPOCO unt = new UserGroupPOCO(); //unt.GroupId = up.GroupId; //unt.GroupName = up.GroupName; list.Add(new KeyValuePair <string, string>(up.GroupId.ToString(), up.GroupName)); //itmasterList.Add(unt); } pOCO.Groups = list; //ViewBag.Groups = itmasterList.Select(x => // new SelectListItem() // { // Text = x.GroupName, // Value = x.GroupId.ToString() // }); return(pOCO); }
//for User drp public void GetAllUserForDrp() { UserGroupBL bL = new UserGroupBL(); List <UserGroupPOCO> pocoList = new List <UserGroupPOCO>(); pocoList = bL.GetAllUserForDrp(/*int.Parse(Session["VesselID"].ToString())*/); List <UserGroupPOCO> itmasterList = new List <UserGroupPOCO>(); foreach (UserGroupPOCO up in pocoList) { UserGroupPOCO unt = new UserGroupPOCO(); unt.UserId = up.UserId; unt.UserName = up.UserName; itmasterList.Add(unt); } ViewBag.Users = itmasterList.Select(x => new SelectListItem() { Text = x.UserName, Value = x.UserId.ToString() }); }
public ActionResult Index() { UserGroupPOCO poco = new UserGroupPOCO(); poco = GetAllGroupsForDrp(); GetAllUserForDrp(); //GetAllGroupsForDrp(); return(View(poco)); }
public int SaveUpdateUserGroup(UserGroupPOCO pOCO) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("stpSaveUpdateUserGroup", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserId", pOCO.UserId); //cmd.Parameters.AddWithValue("@GroupId", pOCO.GroupId); cmd.Parameters.AddWithValue("@SelectedGroup", pOCO.SelectedGroups.ToString()); //cmd.Parameters.AddWithValue("@IsActive", pOCO.IsActive); if (!String.IsNullOrEmpty(pOCO.CreatedBy)) { cmd.Parameters.AddWithValue("@CreatedBy", pOCO.CreatedBy.ToString()); } else { cmd.Parameters.AddWithValue("@CreatedBy", DBNull.Value); } if (!String.IsNullOrEmpty(pOCO.ModifiedBy)) { cmd.Parameters.AddWithValue("@ModifiedBy", pOCO.ModifiedBy.ToString()); } else { cmd.Parameters.AddWithValue("@ModifiedBy", DBNull.Value); } if (pOCO.UserGroupId > 0) { cmd.Parameters.AddWithValue("@UserGroupId ", pOCO.UserGroupId); } else { cmd.Parameters.AddWithValue("@UserGroupId ", DBNull.Value); } int recordsAffected = cmd.ExecuteNonQuery(); con.Close(); return(recordsAffected); }
private List <UserGroupPOCO> ConvertDataTableToUserGroupList(DataSet ds) { List <UserGroupPOCO> pcList = new List <UserGroupPOCO>(); //check if there is at all any data if (ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { UserGroupPOCO pPOCOPC = new UserGroupPOCO(); //if (item["ID"] != null) // pPOCOPC.ID = Convert.ToInt32(item["ID"].ToString()); if (item["UserName"] != System.DBNull.Value) { pPOCOPC.UserName = item["UserName"].ToString(); } if (item["GroupName"] != System.DBNull.Value) { pPOCOPC.GroupName = item["GroupName"].ToString(); } if (item["CreatedBy"] != System.DBNull.Value) { pPOCOPC.CreatedBy = item["CreatedBy"].ToString(); } if (item["ModifiedBy"] != System.DBNull.Value) { pPOCOPC.ModifiedBy = item["ModifiedBy"].ToString(); } pcList.Add(pPOCOPC); } } return(pcList); }
public int SaveUpdateUserGroup(UserGroupPOCO groupMaster /*,int VesselID*/) { UserGroupDAL dAL = new UserGroupDAL(); return(dAL.SaveUpdateUserGroup(groupMaster /*, VesselID*/)); }