Пример #1
0
        public async Task <ResponseData> BicycleAsync([FromBody] CURDRequest <Bicycle> request)
        {
            if (!request.IsValid(true))
            {
                return(new ResponseData(null, false, "用户验证失败"));
            }
            bool result;

            switch (request.Type)
            {
            case "add":
                result = await BicycleAndStationService.AddBicycleAsync(db, request.Item.BicycleID, request.Item.Station.ID);

                return(new ResponseData(null, result));

            case "edit":
                result = await BicycleAndStationService.ModifyBicycleAsync(db, request.Item.ID, request.Item.BicycleID, request.Item.CanHire);

                return(new ResponseData(null, result));

            case "delete":
                result = await BicycleAndStationService.DeleteBicycleAsync(db, request.Item.ID);

                return(new ResponseData(null, result));

            default:
                return(new ResponseData(null, false, "不支持的操作类型"));
            }
        }
Пример #2
0
        public async Task <ResponseData> StationAsync([FromBody] CURDRequest <Station> request)
        {
            if (!request.IsValid(true))
            {
                return(new ResponseData(null, false, "用户验证失败"));
            }
            bool result;

            switch (request.Type)
            {
            case "add":
                await BicycleAndStationService.AddStationAsync(db,
                                                               request.Item.Name,
                                                               request.Item.Address,
                                                               request.Item.Lng,
                                                               request.Item.Lat,
                                                               request.Item.Count);

                return(new ResponseData());

            case "edit":
                result = await BicycleAndStationService.ModifyStationAsync(db,
                                                                           request.Item.ID,
                                                                           request.Item.Name,
                                                                           request.Item.Address,
                                                                           request.Item.Lng,
                                                                           request.Item.Lat,
                                                                           request.Item.Count);

                return(new ResponseData(null, result));

            case "delete":
                result = await BicycleAndStationService.DeleteStationAsync(db, request.Item.ID);

                return(new ResponseData(null, result));

            default:
                return(new ResponseData(null, false, "不支持的操作类型"));
            }
        }