示例#1
0
    // GET api/<controller>
    //public IEnumerable<Student> Get()
    //{

    //    return stud;

    //}

    // GET api/<controller>/5
    //localhost:5024/api/Values/7 night 8 day MV Mahabaahu Upstream Cruise/2018-01-14/248
    public string Get(string pakackagename, DateTime departure, int AgentId)
    {
        string      value       = "";
        HttpContext httpContext = HttpContext.Current;
        string      authHeader  = httpContext.Request.Headers["Authorization"];

        if (authHeader != null && authHeader.StartsWith("Basic"))
        {
            string encodedUsernamePassword = authHeader.Substring("Basic ".Length).Trim();

            AgentMaster oAgentMaster = new AgentMaster();

            AgentDTO[] oAgentData = oAgentMaster.GetApiAuth(AgentId);
            string     TokenNo    = oAgentData[0].TokenNo.ToString();
            if (TokenNo != "" && TokenNo == encodedUsernamePassword)
            {
                var dateAndTime = DateTime.Now;
                var date        = dateAndTime.Date;
                //DateTime d = DateTime.Now.Year;
                DataTable dt1 = dlsr.getpackaageid(pakackagename, departure);
                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    pakackageid = dt1.Rows[0]["PackageId"].ToString();
                    departureId = Convert.ToInt32(dt1.Rows[0]["Id"].ToString());
                }
                DataTable dt = cab.bindroomddl(pakackageid, departureId);
                dv = new DataView();
                dv = new DataView(dt, "BookedStatus='" + "Available" + "'", "BookedStatus", DataViewRowState.CurrentRows);
                DataTable dt2 = dv.ToTable();
                DataSet   ds  = new DataSet();
                ds.Tables.Add(dt2);
                value = ds.GetXml();
                return(value);
            }
            else
            {
                return(value);
            }
        }
        else
        {
            return(value);
        }
    }