コード例 #1
0
        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)));
            }
        }
コード例 #2
0
 public List <ChoiceDto> GetAllChoices()
 {
     using (ChoiceRepository _choiceRepo = new ChoiceRepository())
     {
         return(_choiceRepo.GetAllChoices());
     }
 }
コード例 #3
0
 public void DeleteChoice(int id)
 {
     using (ChoiceRepository _choiceRepo = new ChoiceRepository())
     {
         _choiceRepo.DeleteChoice(id);
     }
 }
コード例 #4
0
 public ChoiceDto AddChoice(ChoiceDto choice)
 {
     using (ChoiceRepository _choiceRepo = new ChoiceRepository())
     {
         return(_choiceRepo.AddChoice(choice));
     }
 }
コード例 #5
0
        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)));
            }
        }
コード例 #6
0
        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)));
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: ChoiceBusiness.cs プロジェクト: tmvan/AppServer
 public ChoiceBusiness(ChoiceRepository choiceRepo)
 {
     _choiceRepo = choiceRepo;
 }