コード例 #1
0
        public ActionResult ChangeStatus(bool status, string tripId)
        {
            var currentUserPhone = User.FindFirst(ClaimTypes.MobilePhone)?.Value;
            var foundTrip        = _tripService.FindById(tripId);

            if (foundTrip != null && foundTrip.Driver.Phone == currentUserPhone)
            {
                foundTrip.IsActive = status;
                var result = _tripService.ChangeStatus(foundTrip);
                if (result)
                {
                    return(Ok(new ResponseModel
                    {
                        Message = "Trip status changed successfully",
                    }));
                }
            }

            return(BadRequest(new ResponseModel
            {
                Message = "Bad request"
            }));
        }