Exemple #1
0
        public ActionResult DeleteMobile(int Id)
        {
            var model = mobileRepository.Get(Id);

            if (model == null)
            {
                return(NotFound());
            }
            mobileRepository.Delete(model);
            return(Ok());
        }
Exemple #2
0
        public async Task <Object> DeleteMobile(int id)
        {
            Mobile mobileToDelte = await _mobileRepo.GetById(id);

            if (mobileToDelte == null)
            {
                return(BadRequest($"le record avec l'id: {id} n'existe pas"));
            }
            await _mobileRepo.Delete(mobileToDelte);

            return(Ok(new { message = "le record est bien été supprimé" }));
        }
        public async Task <IActionResult> undiscoverLocation(int locationId, int userId)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var user = await _repo.GetUser(userId);

            if (user == null)
            {
                return(NotFound());
            }

            var location = await _repo.GetLocation(locationId);

            if (location == null)
            {
                return(NotFound());
            }

            var mobileUserLocation = new MobileUserLocation
            {
                LocationId   = locationId,
                MobileUserId = userId
            };

            _repo.Delete(mobileUserLocation);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to remove location from user"));
        }