public async Task <ActionResult <Tracking_TrackingDTO> > Create([FromBody] Tracking_TrackingDTO Tracking_TrackingDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(Tracking_TrackingDTO.Id))
            {
                return(Forbid());
            }

            Tracking Tracking = ConvertDTOToEntity(Tracking_TrackingDTO);

            Tracking = await TrackingService.Create(Tracking);

            Tracking_TrackingDTO = new Tracking_TrackingDTO(Tracking);
            if (Tracking.IsValidated)
            {
                return(Tracking_TrackingDTO);
            }
            else
            {
                return(BadRequest(Tracking_TrackingDTO));
            }
        }
        private Tracking ConvertDTOToEntity(Tracking_TrackingDTO Tracking_TrackingDTO)
        {
            Tracking Tracking = new Tracking();

            Tracking.Id              = Tracking_TrackingDTO.Id;
            Tracking.TrackerId       = Tracking_TrackingDTO.TrackerId;
            Tracking.TargetId        = Tracking_TrackingDTO.TargetId;
            Tracking.PlaceId         = Tracking_TrackingDTO.PlaceId;
            Tracking.PlaceCheckingId = Tracking_TrackingDTO.PlaceCheckingId;
            Tracking.Place           = Tracking_TrackingDTO.Place == null ? null : new Place
            {
                Id           = Tracking_TrackingDTO.Place.Id,
                Name         = Tracking_TrackingDTO.Place.Name,
                PlaceGroupId = Tracking_TrackingDTO.Place.PlaceGroupId,
                Radius       = Tracking_TrackingDTO.Place.Radius,
                Latitude     = Tracking_TrackingDTO.Place.Latitude,
                Longtitude   = Tracking_TrackingDTO.Place.Longtitude,
            };
            Tracking.PlaceChecking = Tracking_TrackingDTO.PlaceChecking == null ? null : new PlaceChecking
            {
                Id                    = Tracking_TrackingDTO.PlaceChecking.Id,
                AppUserId             = Tracking_TrackingDTO.PlaceChecking.AppUserId,
                PlaceId               = Tracking_TrackingDTO.PlaceChecking.PlaceId,
                PlaceCheckingStatusId = Tracking_TrackingDTO.PlaceChecking.PlaceCheckingStatusId,
                CheckInAt             = Tracking_TrackingDTO.PlaceChecking.CheckInAt,
                CheckOutAt            = Tracking_TrackingDTO.PlaceChecking.CheckOutAt,
            };
            Tracking.Target = Tracking_TrackingDTO.Target == null ? null : new AppUser
            {
                Id          = Tracking_TrackingDTO.Target.Id,
                Username    = Tracking_TrackingDTO.Target.Username,
                Password    = Tracking_TrackingDTO.Target.Password,
                DisplayName = Tracking_TrackingDTO.Target.DisplayName,
                Email       = Tracking_TrackingDTO.Target.Email,
                Phone       = Tracking_TrackingDTO.Target.Phone,
            };
            Tracking.Tracker = Tracking_TrackingDTO.Tracker == null ? null : new AppUser
            {
                Id          = Tracking_TrackingDTO.Tracker.Id,
                Username    = Tracking_TrackingDTO.Tracker.Username,
                Password    = Tracking_TrackingDTO.Tracker.Password,
                DisplayName = Tracking_TrackingDTO.Tracker.DisplayName,
                Email       = Tracking_TrackingDTO.Tracker.Email,
                Phone       = Tracking_TrackingDTO.Tracker.Phone,
            };
            Tracking.BaseLanguage = CurrentContext.Language;
            return(Tracking);
        }
        public async Task <ActionResult <Tracking_TrackingDTO> > Get([FromBody] Tracking_TrackingDTO Tracking_TrackingDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(Tracking_TrackingDTO.Id))
            {
                return(Forbid());
            }

            Tracking Tracking = await TrackingService.Get(Tracking_TrackingDTO.Id);

            return(new Tracking_TrackingDTO(Tracking));
        }