示例#1
0
        // POST api/DriverController

        /// <summary>
        /// To register the driver
        /// </summary>
        /// <param name="userInfo">
        ///     <param name="first_name"></param>
        ///     <param name="last_name"></param>
        ///     <param name="primary_phone_number"></param>
        /// </param>
        /// <param name="registration_number"></param>
        /// <param name="vin"></param>
        /// <param name="passenger_capacity"></param>
        /// <param name="ride_in_progress"></param>
        /// <param name="ideal_location_lat"></param>
        /// <param name="ideal_location_lon"></param>
        /// <returns>
        ///     <param name="status">Status of the API request</param>
        ///     <param name="message">Response message</param>
        /// </returns>
        public Response Post([FromBody] Driver obj)
        {
            AppDao   dbobj       = new AppDao();
            Person   newUser     = new Person();
            Vehicle  newVehicle  = new Vehicle();
            Response responseobj = new Response();

            try
            {
                int driverId;

                responseobj = Get(obj.userInfo.first_name, obj.userInfo.last_name);

                if (responseobj.status == "Sucess" && !responseobj.message.Contains("No user with"))
                {
                    responseobj.status  = "Failed";
                    responseobj.message = "Driver already Exists";
                }
                else
                {
                    newUser.first_name           = obj.userInfo.first_name;
                    newUser.last_name            = obj.userInfo.last_name;
                    newUser.primary_phone_number = obj.userInfo.primary_phone_number;

                    dbobj.Create(newUser);

                    responseobj = Get(newUser.first_name, newUser.last_name);
                    driverId    = Convert.ToInt32(responseobj.message);

                    newVehicle.ideal_location_lat = obj.ideal_location_lat;
                    newVehicle.ideal_location_lon = obj.ideal_location_lon;
                    newVehicle.passenger_capacity = obj.passenger_capacity;
                    newVehicle.vin = obj.vin;
                    newVehicle.registration_number = obj.registration_number;
                    newVehicle.ride_in_progress    = false;
                    newVehicle.person_id           = driverId;

                    dbobj.Create(newVehicle);

                    responseobj.status  = "Sucess";
                    responseobj.message = "Driver added Successfully";
                }
            }
            catch (Exception ex)
            {
                responseobj.status  = "Failed";
                responseobj.message = "Driver adding Failed with error -> " + ex.Message;
            }

            return(responseobj);
        }
示例#2
0
        public JsonResult RegisterApp(string staffCode, string appId, string appName, string appDescription, string appIcon)
        {
            AppDao appDao = new AppDao();
            App    app    = new App
            {
                appId       = appId,
                name        = appName,
                description = appDescription,
                icon        = appIcon
            };

            return(Json(appDao.Create(staffCode, app)));
        }
示例#3
0
        // POST api/PassengerController

        /// <summary>
        /// To Register a new Passenger
        /// </summary>
        /// <param name="first_name">First Name of the Passenger</param>
        /// <param name="last_name">Last Name of the Passenger</param>
        /// <param name="primary_phone_number">Phone Number of the Passenger</param>
        /// <returns>
        ///     <param name="status">Status of the API request</param>
        ///     <param name="message">Response message</param>
        /// </returns>
        public Response Post([FromBody] Person value)
        {
            AppDao           dbobj       = new AppDao();
            Person           newUser     = new Person();
            Response         responseobj = new Response();
            DriverController userInfo    = new DriverController();

            try
            {
                responseobj = userInfo.Get(value.first_name, value.last_name);

                if (responseobj.status == "Sucess" && !responseobj.message.Contains("No user with"))
                {
                    responseobj.status  = "Failed";
                    responseobj.message = "Passanger already Exists";
                }
                else
                {
                    newUser.first_name           = value.first_name;
                    newUser.last_name            = value.last_name;
                    newUser.primary_phone_number = value.primary_phone_number;

                    dbobj.Create(newUser);

                    responseobj.status  = "Sucess";
                    responseobj.message = "User added Successfully";
                }
            }
            catch (Exception ex)
            {
                responseobj.status  = "Failed";
                responseobj.message = "User adding Failed with error -> " + ex.Message;
            }

            return(responseobj);
        }