Exemplo n.º 1
0
        // GET api/DriverController

        /// <summary>
        /// To pass the Id of the person if the firstName and LastName exists
        /// </summary>
        /// <param name="firstName">First Name of the Passenger</param>
        /// <param name="lastName">Last Name of the Passenger</param>
        /// <returns>
        ///     <param name="status">Status of the API request</param>
        ///     <param name="message">Response message if the Id exists or not</param>
        /// </returns>
        public Response Get(string firstName, string lastName)
        {
            AppDao   dbobj       = new AppDao();
            Response responseobj = new Response();
            DataSet  dsResult    = new DataSet();

            try
            {
                string query = "SELECT Id FROM Person WHERE first_name = '" + firstName + "' AND last_name = '" + lastName + "'";

                Identifier resultObj = new Identifier();
                resultObj = dbobj.GetDriverId(query);

                if (resultObj != null)
                {
                    responseobj.status  = "Sucess";
                    responseobj.message = resultObj.Id;
                }
                else
                {
                    responseobj.status  = "Failed";
                    responseobj.message = "No user with the FirstName ='" + firstName + "' and LastName = '" + lastName + "' exists";
                }
            }
            catch (Exception ex)
            {
                responseobj.status  = "Failed";
                responseobj.message = "Driver adding Failed with error -> " + ex.Message;
            }
            return(responseobj);
        }