/// <summary>
 /// Delete a device
 /// </summary>
 /// <param name="deviceId">Device Id</param>
 /// <returns>True if the device was successfully deleted</returns>
 public async Task <bool> DeleteDevice(Guid deviceId)
 {
     if (await _repoDevices.GetItemAsync(deviceId) != null)
     {
         return(await _repoDevices.DeleteItemAsync(deviceId));
     }
     return(true);
 }
        /// <summary>
        /// Delete a response. This call is for debugging purposes only
        /// </summary>
        /// <param name="responseId">Response Id</param>
        /// <param name="responseExists">True if the response exist, will skip the call</param>
        /// <returns>true if the call succeeded</returns>
        public async Task <bool> DeleteResponse(Guid responseId, bool responseExists = false)
        {
            if (!responseExists)
            {
                ResponseDAO response = await _repoResponses.GetItemAsync(responseId);

                if (response == null)
                {
                    throw new Exception($"No response found that matches responseid: {responseId}");
                }
            }

            try
            {
                await _repoResponses.DeleteItemAsync(responseId);
            }
            catch (DocumentClientException e)
            {
                //Update concurrency issue, retrying
                if (e.StatusCode == HttpStatusCode.PreconditionFailed)
                {
                    return(await DeleteResponse(responseId, true));
                }
                throw e;
            }

            return(true);
        }
Esempio n. 3
0
        public async Task <IActionResult> DeleteUserTemplate(string templateId)
        {
            Domain.Model.User currentUser = await EnsureCurrentUser();

            string userId = currentUser.Id.ToLower();

            //Ensure the current user is allowed to edit this template
            Template userTemplate = await _templateRepo.GetItemAsync(templateId);

            if (userTemplate == null || userTemplate.UserId == null || userTemplate.UserId.ToLower() != userId)
            {
                logger.LogError("API DeleteUserTemplate error: Template with id {TemplateId} was found but the user {UserId} does not match.", templateId, userId);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            if (userTemplate.DocType != TemplateDocumentType.User)
            {
                logger.LogError("API DeleteUserTemplate error: Template with id {TemplateId} is not a user template.", templateId, userId);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            //Delete user template
            bool status = await _templateRepo.DeleteItemAsync(templateId);

            if (!status)
            {
                logger.LogError("API DeleteUserTemplate error: There was an error while deleting the template {TemplateId}", templateId);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            return(Ok(status));
        }
        public async Task <IActionResult> DeleteCustomGroups([FromBody] string[] listCustomGroupsIds)
        {
            bool status = false;

            foreach (string customGroupId in listCustomGroupsIds)
            {
                //Ensure the current user is allowed to edit this template
                var customGroupCheck = await _GroupsRepo.GetItemAsync(customGroupId);

                if (customGroupCheck == null)
                {
                    logger.LogError("Delete custom group - Exception: Custom group with id {0} was not found.", customGroupId);
                    return(StatusCode(StatusCodes.Status500InternalServerError));
                }

                //Delete user template
                status = await _GroupsRepo.DeleteItemAsync(customGroupId);

                if (!status)
                {
                    logger.LogError("Delete custom group - Exception: There was an error while deleting the custom group {0}", customGroupId);
                    return(StatusCode(StatusCodes.Status500InternalServerError));
                }
            }
            return(Ok(status));
        }
 /// <summary>
 /// Delete an action plan
 /// </summary>
 /// <param name="actionPlanId">Id of the action plan</param>
 /// <returns>True if the action plan was removed</returns>
 public async Task <bool> DeleteActionPlan(Guid actionPlanId)
 {
     if (await _repoActionPlans.GetItemAsync(actionPlanId) != null)
     {
         return(await _repoActionPlans.DeleteItemAsync(actionPlanId));
     }
     return(true);
 }
Esempio n. 6
0
        public async Task <bool> DeleteNoteTemplate(string noteTemplateid)
        {
            bool result = await _repoNoteTemplates.DeleteItemAsync(noteTemplateid);

            if (result)
            {
                _dictNoteTemplates?.Remove(noteTemplateid);
            }
            return(result);
        }
        public async Task <bool> DeleteEvent(string eventId)
        {
            bool result = await _repoEvents.DeleteItemAsync(eventId);

            if (result)
            {
                _dictEvents?.Remove(eventId);
            }
            return(result);
        }
Esempio n. 8
0
        public async Task DeleteAsync(string id)
        {
            Patient item = await Respository.GetItemAsync(id);

            // just using the manager to do something extra

            if (item == null)
            {
                throw new Exception("Id can not be found");
            }
            await Respository.DeleteItemAsync(id, item.Address.ZipCode);
        }
Esempio n. 9
0
        public async Task DeleteAsync(string id)
        {
            Doctor item = await Respository.GetItemAsync(id);

            // just using the manager to do something extra

            if (item == null)
            {
                throw new Exception("Id can not be found");
            }
            await Respository.DeleteItemAsync(id, item.Speciality.Id);
        }
Esempio n. 10
0
        /// <summary>
        /// Delete all messages from the collection "Message" before attempting a new simulation
        /// </summary>
        /// <returns></returns>
        private async Task DeleteOldCosmosMessages()
        {
            IEnumerable <CosmosDBMessage> messageEnum = await _MessageRepo.GetItemsAsync(p => p.IoTHub != null && p.IoTHub.ConnectionDeviceId == AppConfig.IoTHub.SimulatorDeviceName);

            if (messageEnum != null)
            {
                IEnumerator <CosmosDBMessage> enumerator = messageEnum.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    await _MessageRepo.DeleteItemAsync(enumerator.Current.Id.ToString());
                }
            }
            return;
        }
 public async Task <bool> DeleteUserConversation(string userId)
 {
     return(await _repoChatUserSessions.DeleteItemAsync(userId));
 }
Esempio n. 12
0
        public async Task <ActionResult> DeleteConfirmedAsync([Bind("Id")] string id)
        {
            await _cosmosDBRepository.DeleteItemAsync(id);

            return(RedirectToAction("Index"));
        }
Esempio n. 13
0
 public void Delete(string id)
 {
     _cosmosDBRepository.DeleteItemAsync(id).Wait();
 }
        public async Task <IActionResult> OnGetDeleteMovieAsync(string id)
        {
            await cosmosDbRepository.DeleteItemAsync(id);

            return(RedirectToPage(routeName));
        }