public AllMasterData GetMasterData()
        {
            AllMasterData res = new AllMasterData();

            try
            {
                query     = "Sp_MasterDataWebApi";
                dbcommand = new SqlCommand(query, conn);
                dbcommand.Connection.Open();
                dbcommand.CommandType = CommandType.StoredProcedure;
                dbcommand.Parameters.AddWithValue("@QueryType", "GetMasterData");

                SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                DataSet        dt = new DataSet();
                da.Fill(dt);

                List <SiteList> SiteList = new List <SiteList>();
                foreach (DataRow row in dt.Tables[7].Rows)
                {
                    SiteList A = new SiteList();
                    A.id   = row["id"].ToString();
                    A.name = row["name"].ToString();
                    SiteList.Add(A);
                }
                res.SiteListData = SiteList;

                List <Aisle> AisleList = new List <Aisle>();

                foreach (DataRow row in dt.Tables[0].Rows)
                {
                    Aisle A = new Aisle();
                    A.id   = Convert.ToInt64(row["id"]);
                    A.name = row["name"].ToString();
                    AisleList.Add(A);
                }

                List <Rack> RackList = new List <Rack>();

                foreach (DataRow row in dt.Tables[1].Rows)
                {
                    Rack R = new Rack();
                    R.id   = Convert.ToInt64(row["id"]);
                    R.name = row["name"].ToString();
                    RackList.Add(R);
                }


                List <Bin> BinList = new List <Bin>();
                foreach (DataRow row in dt.Tables[2].Rows)
                {
                    Bin A = new Bin();
                    A.id   = Convert.ToInt64(row["id"]);
                    A.name = row["name"].ToString();
                    BinList.Add(A);
                }



                List <Reason> ReasonList = new List <Reason>();
                foreach (DataRow row in dt.Tables[3].Rows)
                {
                    Reason A = new Reason();
                    A.id   = Convert.ToInt64(row["id"]);
                    A.name = row["name"].ToString();
                    ReasonList.Add(A);
                }

                List <FLTList> FLTList = new List <FLTList>();
                foreach (DataRow row in dt.Tables[4].Rows)
                {
                    FLTList A = new FLTList();
                    A.id   = Convert.ToInt64(row["id"]);
                    A.name = row["name"].ToString();
                    FLTList.Add(A);
                }
                List <WareHouseList> WareHouseList = new List <WareHouseList>();
                foreach (DataRow row in dt.Tables[5].Rows)
                {
                    WareHouseList A = new WareHouseList();
                    A.id   = row["id"].ToString();;
                    A.name = row["name"].ToString();
                    WareHouseList.Add(A);
                }

                res.AisleList     = AisleList;
                res.RackList      = RackList;
                res.BinList       = BinList;
                res.ReasonList    = ReasonList;
                res.FLTList       = FLTList;
                res.WareHouseList = WareHouseList;
                res.Status        = "Success";
                res.Message       = "Data retrived successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "Failure";
                res.Message = ex.Message;
            }
            finally
            {
                dbcommand.Connection.Close();
            }
            return(res);
        }
        public AssigningResponse AssignData(AssigningReq CMR)
        {
            AssigningResponse res = new AssigningResponse();

            try
            {
                if (CMR == null)
                {
                    res.Status  = "Failure";
                    res.Message = "Object reference not set to an instance of an object.";
                }
                else if (CMR.StickerNo == "")
                {
                    res.Status  = "Failure";
                    res.Message = "Invalid Sticker No.";
                }
                else
                {
                    query     = "Sp_AssignWebApi";
                    dbcommand = new SqlCommand(query, conn);
                    dbcommand.Connection.Open();
                    dbcommand.CommandType = CommandType.StoredProcedure;
                    dbcommand.Parameters.AddWithValue("@QueryType", "GetAssignedData");
                    dbcommand.Parameters.AddWithValue("@StickerId", CMR.StickerNo);
                    dbcommand.Parameters.AddWithValue("@UserId", CMR.UserId);
                    dbcommand.CommandTimeout = 0;
                    SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                    if (ds.Tables[0].Rows[0]["value"].ToString() != "3")
                    {
                        res.StillageLocation = Convert.ToString(ds.Tables[0].Rows[0]["StillageLocation"]);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["value"].ToString() == "1")
                            {
                                res.Status  = "Failure";
                                res.Message = "Don't have access to get the details";
                            }

                            //else if (res.StillageLocation != "NPRO-000001")
                            else
                            {
                                res.StickerID        = ds.Tables[0].Rows[0]["StickerID"].ToString();
                                res.StandardQty      = Convert.ToDecimal(ds.Tables[0].Rows[0]["StandardQty"]);
                                res.ItemId           = ds.Tables[0].Rows[0]["ItemId"].ToString();
                                res.Description      = ds.Tables[0].Rows[0]["Description"].ToString();
                                res.ItemStdQty       = Convert.ToDecimal(ds.Tables[0].Rows[0]["ItemStdQty"]);
                                res.WareHouseID      = Convert.ToString(ds.Tables[0].Rows[0]["WareHouseID"]);
                                res.IsAssignTransfer = Convert.ToByte(ds.Tables[0].Rows[0]["IsAssignTransfer"]);

                                List <AisleList> AisleList = new List <AisleList>();
                                foreach (DataRow row in ds.Tables[1].Rows)
                                {
                                    AisleList A = new AisleList();
                                    A.name = row["name"].ToString();
                                    A.id   = row["id"].ToString();
                                    AisleList.Add(A);
                                }
                                res.AisleList = AisleList;

                                //List<BinList> BinList = new List<BinList>();
                                //foreach (DataRow row in ds.Tables[3].Rows)
                                //{
                                //    BinList A = new BinList();
                                //    A.name = row["name"].ToString();
                                //    A.id = row["id"].ToString();
                                //    BinList.Add(A);
                                //}
                                //res.BinList = BinList;

                                //List<RackList> RackList = new List<RackList>();
                                //foreach (DataRow row in ds.Tables[2].Rows)
                                //{
                                //    RackList A = new RackList();
                                //    A.name = row["name"].ToString();
                                //    A.id = row["id"].ToString();
                                //    RackList.Add(A);
                                //}
                                //res.RackList = RackList;
                                List <ZoneList> ZoneList = new List <ZoneList>();
                                foreach (DataRow row in ds.Tables[2].Rows)
                                {
                                    ZoneList A = new ZoneList();
                                    A.name = row["name"].ToString();
                                    A.id   = row["id"].ToString();
                                    ZoneList.Add(A);
                                }
                                res.ZoneList = ZoneList;

                                List <FLTList> FLTList = new List <FLTList>();
                                foreach (DataRow row in ds.Tables[3].Rows)
                                {
                                    FLTList A = new FLTList();
                                    A.name = row["name"].ToString();
                                    A.id   = Convert.ToInt64(row["id"]);
                                    FLTList.Add(A);
                                }
                                res.FLTList = FLTList;



                                res.Status  = "Success";
                                res.Message = "Data retrived successfully";
                            }
                            //else
                            //{
                            //    res.Status = "Operation Invalid";
                            //    res.Message = "Stillage will only move to Loading Area.";

                            //}
                        }
                        else
                        {
                            res.Status  = "Failure";
                            res.Message = "Invalid Sticker Id";
                        }
                    }
                    else
                    {
                        res.Status  = "Failure";
                        res.Message = "This stillage does not exist";
                        return(res);
                    }
                }
            }
            catch (Exception Ex)
            {
                res.Status  = "Failure";
                res.Message = Ex.Message;
            }
            finally
            {
                dbcommand.Connection.Close();
            }
            return(res);
        }