public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = null)] HttpRequest req, ExecutionContext executionContext) { try { string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); if (string.IsNullOrEmpty(requestBody)) { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(new RequestBodyEmptyException()))); } Choice data = JsonConvert.DeserializeObject <Choice>(requestBody); Choice results = ChoiceRepository.CreateNew(executionContext, "ChoiceUpdate").AddOrUpdate(data); if (results == null || results.PrimaryKey == 0) { return((ActionResult) new OkObjectResult(new InsertRecordException(data.Text))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(results))); } } catch (Exception e) { return((ActionResult) new BadRequestObjectResult(new UpdateRecordException(typeof(Scene).Name))); } }
public List <ChoiceDto> GetAllChoices() { using (ChoiceRepository _choiceRepo = new ChoiceRepository()) { return(_choiceRepo.GetAllChoices()); } }
public void DeleteChoice(int id) { using (ChoiceRepository _choiceRepo = new ChoiceRepository()) { _choiceRepo.DeleteChoice(id); } }
public ChoiceDto AddChoice(ChoiceDto choice) { using (ChoiceRepository _choiceRepo = new ChoiceRepository()) { return(_choiceRepo.AddChoice(choice)); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ExecutionContext executionContext) { IEnumerable <Choice> results = ChoiceRepository.CreateNew(executionContext, "ChoicesList").GetAll(); if (results == null || results.Count() == 0) { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(new ErrorReadingDataFile(typeof(Choice).Name)))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(results))); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ExecutionContext executionContext) { Choice data = await req.GetFromBody <Choice>(); Choice choice = ChoiceRepository.CreateNew(executionContext, "Choice").GetByPK(data.PrimaryKey); if (choice == null) { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(new PrimaryKeyNotFoundException(data.PrimaryKey)))); } else { return((ActionResult) new OkObjectResult(new RequestResponse <Choice>(choice))); } }
public Choice RetrieveMetricChoice(int workspaceArtifactId, int choiceArtifactId) { Choice metricChoice; try { try { RsapiApiOptions.WorkspaceID = workspaceArtifactId; metricChoice = ChoiceRepository.ReadSingle(choiceArtifactId); } catch (Exception ex) { throw new Exception($"{Constants.ErrorMessages.RETRIEVE_METRIC_CHOICE_ERROR}. ReadSingle. [{nameof(workspaceArtifactId)}= {workspaceArtifactId}, {nameof(choiceArtifactId)}= {choiceArtifactId}]", ex); } } catch (Exception ex) { throw new Exception(Constants.ErrorMessages.RETRIEVE_METRIC_CHOICE_ERROR, ex); } return(metricChoice); }
public ChoiceBusiness(ChoiceRepository choiceRepo) { _choiceRepo = choiceRepo; }