Пример #1
0
        public JsonResult AssignStationtoUser(UserLocationMapper assignstationdata)
        {
            string success = "";

            try
            {
                int result = usersDAL_obj.AssignStationtoUser(assignstationdata, Convert.ToString(Session["UserID"]));
                if (result > 0)
                {
                    success = "Success";
                }
                else if (result == -1)
                {
                    success = "Data Exists";
                }
                else
                {
                    success = "Failed";
                }

                return(Json(success, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("Fail", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AddOperatortoLot(string operatorID, UserLocationMapper LotDetails)
        {
            string success = "";

            try
            {
                success = userlocationMapperDAL_obj.AddOperatortoLot(Convert.ToString(operatorID), LotDetails, Convert.ToInt32(Session["UserID"]), Convert.ToString(Session["UserID"]));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(success, JsonRequestBehavior.AllowGet));
        }
        public IList <UserLocationMapper> GetAssignStationList(int UserID)
        {
            IList <UserLocationMapper> lst = new List <UserLocationMapper>();

            sqlhelper_obj = new SqlHelper();
            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection())
                {
                    sqlconn_obj.ConnectionString = sqlhelper_obj.GetConnectionSrting();

                    using (SqlCommand sqlcmd_getlots_obj = new SqlCommand("PARK_PROC_GetAssignedStationsbyUserID", sqlconn_obj))
                    {
                        sqlcmd_getlots_obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_getlots_obj.CommandTimeout = 0;
                        sqlcmd_getlots_obj.Parameters.AddWithValue("@UserID", UserID);
                        DataSet ds;
                        using (SqlDataAdapter da = new SqlDataAdapter(sqlcmd_getlots_obj))
                        {
                            ds = new DataSet();
                            da.Fill(ds);
                        }
                        DataTable dt = ds.Tables[0];

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            UserLocationMapper user_obj = new UserLocationMapper();
                            user_obj.UserLocationMapperID = Convert.ToInt32(dt.Rows[i]["UserLocationMapperID"]);
                            user_obj.UserID                 = Convert.ToInt32(dt.Rows[i]["UserID"]);
                            user_obj.LocationID             = Convert.ToInt32(dt.Rows[i]["LocationID"]);
                            user_obj.LocationName           = Convert.ToString(dt.Rows[i]["LocationName"]);
                            user_obj.LocationParkingLotID   = Convert.ToInt32(dt.Rows[i]["LotID"]);
                            user_obj.LocationParkingLotName = Convert.ToString(dt.Rows[i]["LocationParkingLotName"]);
                            user_obj.IsActive               = Convert.ToBoolean(dt.Rows[i]["IsActive"]);
                            user_obj.UpdatedOn              = dt.Rows[i]["UpdatedOn"] == DBNull.Value ? Convert.ToDateTime(null) : Convert.ToDateTime(dt.Rows[i]["UpdatedOn"]);
                            lst.Add(user_obj);
                        }
                    }
                }
                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonNetResult GetOperatorsLoginStatusByLocationandLot(UserLocationMapper SearchData)
        {
            IList <UserLocationMapper> usersList = userlocationMapperDAL_obj.GetOperatorsLoginStatusByLocationandLot(SearchData, Convert.ToInt32(Session["UserID"]), Convert.ToString(Session["UserType"]));

            try
            {
                return(new JsonNetResult()
                {
                    Data = usersList,
                    MaxJsonLength = 2147483647
                });
            }
            catch (Exception ex)
            {
                return(new JsonNetResult {
                    Data = "Failed"
                });
            }
        }
        public List <UserLocationMapper> GetAssignStationByID(int UserLocationMapperID)
        {
            sqlhelper_obj = new SqlHelper();
            List <UserLocationMapper> list = new List <UserLocationMapper>();

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection())
                {
                    sqlconn_obj.ConnectionString = sqlhelper_obj.GetConnectionSrting();
                    using (SqlCommand sqlcmd_details_obj = new SqlCommand("PARK_PROC_ViewUserLocationMapperDetails", sqlconn_obj))
                    {
                        sqlcmd_details_obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_details_obj.CommandTimeout = 0;
                        sqlcmd_details_obj.Parameters.AddWithValue("@UserLocationMapperID", UserLocationMapperID);
                        DataSet ds;
                        using (SqlDataAdapter sql_dp = new SqlDataAdapter(sqlcmd_details_obj))
                        {
                            ds = new DataSet();
                            sql_dp.Fill(ds);
                        }
                        DataTable dt = ds.Tables[0];

                        if (dt.Rows.Count > 0)
                        {
                            DataRow            row     = dt.Rows[0];
                            UserLocationMapper map_obj = new UserLocationMapper();
                            map_obj.UserLocationMapperID = Convert.ToInt32(row["UserLocationMapperID"]);
                            map_obj.UserID               = Convert.ToInt32(row["UserID"]);
                            map_obj.LocationID           = Convert.ToInt32(row["LocationID"]);
                            map_obj.LocationParkingLotID = Convert.ToInt32(row["LotID"]);
                            map_obj.IsActive             = Convert.ToBoolean(row["IsActive"]);
                            list.Add(map_obj);
                        }
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult AssignOperatortoLot(string operatorID, UserLocationMapper LotDetails, string absentUserID)
        {
            string success = "";

            //string[] values = operatorID.Split(',');

            try
            {
                success = userlocationMapperDAL_obj.AssignOperatortoLot(Convert.ToString(operatorID), LotDetails, Convert.ToInt32(Session["UserID"]), Convert.ToString(Session["UserID"]), Convert.ToInt32(absentUserID));
                //for (int i = 0; i < values.Length; i++)
                //{
                //    success = userlocationMapperDAL_obj.AssignOperatortoLot(Convert.ToInt32(values[i].ToString()), LotDetails, Convert.ToInt32(Session["UserID"]), Convert.ToString(Session["UserID"]),Convert.ToInt32(absentUserID));
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(success, JsonRequestBehavior.AllowGet));
        }
        //public string AssignOperatortoLot(int operatorID, UserLocationMapper data, int supervisorID, string CreatedBy,int absentUserID)
        public string AssignOperatortoLot(string operatorID, UserLocationMapper data, int supervisorID, string CreatedBy, int absentUserID)
        {
            sqlhelper_obj = new SqlHelper();
            string status = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection())
                {
                    sqlconn_obj.ConnectionString = sqlhelper_obj.GetConnectionSrting();
                    using (SqlCommand sqlcmd_obj = new SqlCommand("PARK_PROC_AssignLottoOperatorBySupervisor", sqlconn_obj))
                    {
                        //PARK_PROC_AssignLottoOperatorBySupervisor
                        sqlcmd_obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_obj.CommandTimeout = 0;
                        sqlcmd_obj.Parameters.AddWithValue("@UserID", operatorID);
                        sqlcmd_obj.Parameters.AddWithValue("@LocationID", data.LocationID);
                        sqlcmd_obj.Parameters.AddWithValue("@LocationParkingLotID", data.LocationParkingLotID);
                        sqlcmd_obj.Parameters.AddWithValue("@SupervisorID", supervisorID);
                        sqlcmd_obj.Parameters.AddWithValue("@CreatedBy", CreatedBy);
                        sqlcmd_obj.Parameters.AddWithValue("@AbsentUserID", absentUserID);
                        sqlconn_obj.Open();
                        int result = sqlcmd_obj.ExecuteNonQuery();
                        sqlconn_obj.Close();
                        if (result > 0)
                        {
                            status = "Success";
                        }
                        else
                        {
                            status = "Failed";
                        }
                    }
                }
                return(status);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <UserLocationMapper> GetOperatorsLoginStatusByLocationandLot(UserLocationMapper SearchData, int supervisorID, string UserType)
        {
            List <UserLocationMapper> userslocationList = new List <UserLocationMapper>();

            sqlhelper_obj = new SqlHelper();
            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection())
                {
                    sqlconn_obj.ConnectionString = sqlhelper_obj.GetConnectionSrting();

                    using (SqlCommand sqlcmd_getusers_obj = new SqlCommand("PARK_PROC_GetAssignOperatorsForSupervisorByLocation", sqlconn_obj))
                    {
                        sqlcmd_getusers_obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_getusers_obj.CommandTimeout = 0;
                        sqlcmd_getusers_obj.Parameters.AddWithValue("@LocationID", Convert.ToInt32(SearchData.LocationID));
                        if (Convert.ToString(SearchData.LocationParkingLotID) != "" && SearchData.LocationParkingLotID != 0)
                        {
                            sqlcmd_getusers_obj.Parameters.AddWithValue("@LocationParkingLotID", Convert.ToInt32(SearchData.LocationParkingLotID));
                        }
                        else
                        {
                            sqlcmd_getusers_obj.Parameters.AddWithValue("@LocationParkingLotID", DBNull.Value);
                        }
                        sqlcmd_getusers_obj.Parameters.AddWithValue("@SupervisorID", supervisorID);
                        sqlcmd_getusers_obj.Parameters.AddWithValue("@UserType", UserType);
                        DataSet ds;
                        using (SqlDataAdapter da = new SqlDataAdapter(sqlcmd_getusers_obj))
                        {
                            ds = new DataSet();
                            da.Fill(ds);
                        }
                        DataTable dt = ds.Tables[0];

                        #region New Code
                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            UserLocationMapper users_obj = new UserLocationMapper();
                            User        user;
                            List <User> list = new List <User>();

                            if (dt.Rows[j]["UserID"] != null && dt.Rows[j]["UserID"] != DBNull.Value) //031220
                            {                                                                         //031220
                                if (!userslocationList.Any(t => (t.UserID == Convert.ToInt32(dt.Rows[j]["UserID"]) &&
                                                                 t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]))))
                                {
                                    if (!userslocationList.Any(t => t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]))) //New
                                    {                                                                                                               //New
                                        users_obj.UserID                 = Convert.ToInt32(dt.Rows[j]["UserID"]);
                                        users_obj.LocationID             = Convert.ToInt32(dt.Rows[j]["LocationID"]);
                                        users_obj.LocationParkingLotID   = Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]);
                                        users_obj.UserName               = Convert.ToString(dt.Rows[j]["UserName"]);
                                        users_obj.LocationName           = Convert.ToString(dt.Rows[j]["LocationName"]);
                                        users_obj.LocationParkingLotName = Convert.ToString(dt.Rows[j]["LocationParkingLotName"]);
                                        users_obj.LoginTime              = Convert.ToString(dt.Rows[j]["LoginTime"]);

                                        if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) != "")//login time block add
                                        {
                                            user                     = new User();
                                            user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                            user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);

                                            user.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                            user.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);


                                            list.Add(user);
                                            users_obj.userslist = list;
                                        }
                                        else if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) == "")//login time block add
                                        {
                                            user                     = new User();
                                            user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                            user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);

                                            user.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                            user.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);

                                            list.Add(user);
                                            users_obj.userslist = list;
                                        }
                                        users_obj.AssignedUserID   = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                        users_obj.AssignedUserName = Convert.ToString(dt.Rows[j]["AssignedUserName"]);

                                        users_obj.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);

                                        users_obj.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                        users_obj.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);

                                        userslocationList.Add(users_obj);
                                    }    //New
                                    else //New
                                    {//New
                                        int index1 = userslocationList.FindIndex(t => (t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"])));

                                        if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) != "")//login time block add
                                        {
                                            user                     = new User();
                                            user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                            user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);

                                            user.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                            user.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);

                                            list.Add(user);
                                            users_obj.userslist = list;
                                            userslocationList[index1].userslist.Add(user);
                                        }
                                        else if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) == "")//login time block add
                                        {
                                            user                     = new User();
                                            user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                            user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);

                                            user.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                            user.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);

                                            list.Add(user);
                                            users_obj.userslist = list;
                                            userslocationList[index1].userslist.Add(user);
                                        }
                                        else
                                        {
                                            user                     = new User();
                                            user.UserName            = Convert.ToString(dt.Rows[j]["UserName"]);
                                            user.UserID              = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);
                                            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["LoginTime"]);

                                            user.AbsentUserID  = dt.Rows[j]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["UserID"]);//New
                                            user.OperatorExist = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);

                                            list.Add(user);
                                            users_obj.userslist = list;
                                            userslocationList[index1].userslist.Add(user);
                                        }
                                    }//New
                                }
                                else
                                {
                                    if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) != "")//login time block add
                                    {
                                        int index = userslocationList.FindIndex(t => (t.UserID == Convert.ToInt32(dt.Rows[j]["UserID"]) &&
                                                                                      t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"])));
                                        user                     = new User();
                                        user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                        user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                        user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);
                                        user.OperatorExist       = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);
                                        list.Add(user);
                                        users_obj.userslist = list;
                                        userslocationList[index].userslist.Add(user);
                                    }
                                    else if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "" && Convert.ToString(dt.Rows[j]["LoginTime"]) == "")//login time block add
                                    {
                                        int index = userslocationList.FindIndex(t => (t.UserID == Convert.ToInt32(dt.Rows[j]["UserID"]) &&
                                                                                      t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"])));
                                        user                     = new User();
                                        user.UserName            = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                                        user.UserID              = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                                        user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);
                                        user.OperatorExist       = Convert.ToBoolean(dt.Rows[j]["OperatorExist"]);
                                        list.Add(user);
                                        users_obj.userslist = list;
                                        userslocationList[index].userslist.Add(user);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }//031220
                            else if (!userslocationList.Any(t => (t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]))))//031220
                            {//031220
                                users_obj.LocationID             = Convert.ToInt32(dt.Rows[j]["LocationID"]);
                                users_obj.LocationParkingLotID   = Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]);
                                users_obj.LocationName           = Convert.ToString(dt.Rows[j]["LocationName"]);
                                users_obj.LocationParkingLotName = Convert.ToString(dt.Rows[j]["LocationParkingLotName"]);
                                users_obj.LoginTime     = Convert.ToString(dt.Rows[j]["LoginTime"]);
                                users_obj.OperatorExist = false;
                                userslocationList.Add(users_obj);
                            }//031220
                        }
                        #endregion

                        #region Old Code
                        //for (int j = 0; j < dt.Rows.Count; j++)
                        //{
                        //    UserLocationMapper users_obj = new UserLocationMapper();
                        //    User user;
                        //    List<User> list = new List<User>();

                        //    if (!userslocationList.Any(t => (t.UserID == Convert.ToInt32(dt.Rows[j]["UserID"])
                        //            && t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]))))
                        //    {
                        //        users_obj.UserID = Convert.ToInt32(dt.Rows[j]["UserID"]);
                        //        users_obj.LocationID = Convert.ToInt32(dt.Rows[j]["LocationID"]);
                        //        users_obj.LocationParkingLotID = Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"]);
                        //        users_obj.UserName = Convert.ToString(dt.Rows[j]["UserName"]);
                        //        users_obj.LocationName = Convert.ToString(dt.Rows[j]["LocationName"]);
                        //        users_obj.LocationParkingLotName = Convert.ToString(dt.Rows[j]["LocationParkingLotName"]);
                        //        users_obj.LoginTime = Convert.ToString(dt.Rows[j]["LoginTime"]);

                        //        if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "")
                        //        {
                        //            user = new User();
                        //            user.UserName = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                        //            user.UserID = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                        //            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);
                        //            list.Add(user);
                        //            users_obj.userslist = list;
                        //        }
                        //        users_obj.AssignedUserID = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                        //        users_obj.AssignedUserName = Convert.ToString(dt.Rows[j]["AssignedUserName"]);

                        //        users_obj.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);
                        //        userslocationList.Add(users_obj);
                        //    }
                        //    else
                        //    {
                        //        if (Convert.ToString(dt.Rows[j]["AssignedUserName"]) != "" && Convert.ToString(dt.Rows[j]["AssignedUserID"]) != "")
                        //        {
                        //            int index = userslocationList.FindIndex(t => (t.UserID == Convert.ToInt32(dt.Rows[j]["UserID"])
                        //                                    && t.LocationParkingLotID == Convert.ToInt32(dt.Rows[j]["LocationParkingLotID"])));
                        //            user = new User();
                        //            user.UserName = Convert.ToString(dt.Rows[j]["AssignedUserName"]);
                        //            user.UserID = dt.Rows[j]["AssignedUserID"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[j]["AssignedUserID"]);
                        //            user.AssignUserLoginTime = Convert.ToString(dt.Rows[j]["AssignUserLoginTime"]);
                        //            list.Add(user);
                        //            users_obj.userslist = list;
                        //            userslocationList[index].userslist.Add(user);
                        //        }
                        //        else
                        //        {
                        //            break;
                        //        }
                        //    }
                        //}
                        #endregion
                    }
                }
                for (int y = 0; y < userslocationList.Count; y++)
                {
                    userslocationList[y].userslist = userslocationList[y].userslist.GroupBy(x => x.UserID).Select(x => x.First()).ToList();
                }
                return(userslocationList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int AssignStationtoUser(UserLocationMapper userstation_data, string CreatedBy)
        {
            sqlhelper_obj = new SqlHelper();
            int    result;
            string data_status = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection())
                {
                    sqlconn_obj.ConnectionString = sqlhelper_obj.GetConnectionSrting();

                    //if (Convert.ToString(userstation_data.AssignedLotID) != "" && userstation_data.AssignedLotID != 0)
                    //{
                    using (SqlCommand sqlcmd_details_obj = new SqlCommand("PARK_PROC_AssignStationtoEmployee", sqlconn_obj))
                    {
                        sqlcmd_details_obj.CommandType    = CommandType.StoredProcedure;
                        sqlcmd_details_obj.CommandTimeout = 0;

                        if (userstation_data.UserLocationMapperID.ToString() != "" && userstation_data.UserLocationMapperID != 0)
                        {
                            sqlcmd_details_obj.Parameters.AddWithValue("@StmtType", "Update");
                            sqlcmd_details_obj.Parameters.AddWithValue("@UserLocationMapperID", userstation_data.UserLocationMapperID);
                        }
                        else
                        {
                            sqlcmd_details_obj.Parameters.AddWithValue("@StmtType", "Insert");
                            sqlcmd_details_obj.Parameters.AddWithValue("@UserLocationMapperID", DBNull.Value);
                        }

                        sqlcmd_details_obj.Parameters.AddWithValue("@UserID", userstation_data.UserID);
                        sqlcmd_details_obj.Parameters.AddWithValue("@LocationID", userstation_data.LocationID);
                        sqlcmd_details_obj.Parameters.AddWithValue("@LotID", userstation_data.LocationParkingLotID);
                        sqlcmd_details_obj.Parameters.AddWithValue("@UpdatedBy", CreatedBy);
                        sqlcmd_details_obj.Parameters.Add("@Output_identity", SqlDbType.Int).Direction = ParameterDirection.Output;

                        if (userstation_data.IsActive.ToString() == "")
                        {
                            sqlcmd_details_obj.Parameters.AddWithValue("@IsActive", true);
                        }
                        else
                        {
                            sqlcmd_details_obj.Parameters.AddWithValue("@IsActive", Convert.ToBoolean(userstation_data.IsActive));
                        }

                        sqlconn_obj.Open();
                        int res = sqlcmd_details_obj.ExecuteNonQuery();
                        result = Convert.ToInt32(sqlcmd_details_obj.Parameters["@Output_identity"].Value);
                        sqlconn_obj.Close();
                    }
                    // }
                    //else
                    //{

                    //    for (int k = 0; k < userstation_data.AssignedLocationID.ToString().Length - 1; k++)
                    //    {
                    //        int location = Convert.ToInt32(userstation_data.AssignedLocationID.ToString().Split(',')[k]);


                    //        using (SqlCommand sqlcmd_details_obj = new SqlCommand("PARK_PROC_AssignStationtoEmployee", sqlconn_obj))
                    //        {
                    //            sqlcmd_details_obj.CommandType = CommandType.StoredProcedure;
                    //            sqlcmd_details_obj.CommandTimeout = 0;

                    //            sqlcmd_details_obj.Parameters.AddWithValue("@UserID", userstation_data.UserID);
                    //            sqlcmd_details_obj.Parameters.AddWithValue("@LocationID", location);
                    //            sqlcmd_details_obj.Parameters.AddWithValue("@LotID", DBNull.Value);

                    //            sqlcmd_details_obj.Parameters.AddWithValue("@UpdatedBy", CreatedBy);

                    //            sqlconn_obj.Open();
                    //            int result = sqlcmd_details_obj.ExecuteNonQuery();
                    //            sqlconn_obj.Close();
                    //            if (result > 0)
                    //            {
                    //                data_status = "Success";
                    //            }
                    //            else
                    //            {
                    //                data_status = "Failed";
                    //            }
                    //        }
                    //    }
                    //}
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }