/// <summary> /// Create an action plan /// </summary> /// <param name="actionPlanObj">ActionPlanCreationModel</param> /// <returns>ActionPlanModel</returns> public async Task <ActionPlanModel> CreationActionPlan(ActionPlanCreationModel actionPlanObj) { ActionPlanDAO plan = _mapper.Map <ActionPlanDAO>(actionPlanObj); plan.Id = await _repoActionPlans.CreateItemAsync(plan); if (_repoActionPlans.IsDocumentKeyNull(plan)) { throw new Exception($"An error occured when creating a new action plan"); } return(_mapper.Map <ActionPlanModel>(plan)); }
public async Task <ActionPlanModel> CreateActionPlan(ActionPlanCreationModel actionPlanObj) { RestRequest request = await PrepareQuery("ActionPlans", Method.POST); request.AddParameter("application/json", JsonConvert.SerializeObject(actionPlanObj), ParameterType.RequestBody); var queryResult = await _client.ExecuteTaskAsync <ActionPlanModel>(request); if (queryResult.IsSuccessful) { return(queryResult.Data); } else { _logger.LogError($"CreationModel: Error while adding a device: {queryResult.StatusCode}"); } return(null); }
public async Task <IActionResult> CreationActionPlan(ActionPlanCreationModel actionPlanObj) { var result = await _actionPlanDataManager.CreationActionPlan(actionPlanObj); return(Ok(result)); }