Beispiel #1
0
        public async Task <ActionResult> Get()
        {
            var client = ImageAnnotatorClient.Create();
            //ImageAnnotatorClient.Create()
            var labelsModel     = new LabelsModel();
            var labelsModelList = new List <LabelsModel>();
            var image           = Image.FromUri("gs://cloud-vision-codelab/otter_crossing.jpg");

            //var response = client.DetectText(image);
            var response = await client.DetectLabelsAsync(image);

            foreach (var label in response)
            {
                var label2 = new LabelsModel();
                if (label != null)
                {
                    label2.Description = label.Description;
                    label2.Score       = label.Score;
                }

                labelsModelList.Add(label2);
            }
            ;
            return(Ok(labelsModelList));
        }
        public void DeleteLabel(int id)
        {
            LabelsModel label  = context.labels.Where(t => t.Id == id).FirstOrDefault();
            int         result = 0;

            try
            {
                this.context.labels.Remove(label);
                result = context.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
        public string UpdateLabels(int id, string newlabel)
        {
            LabelsModel labels = context.labels.Where(t => t.Id == id).FirstOrDefault();

            labels.Labels = newlabel;
            int result = 0;

            try
            {
                result = this.context.SaveChanges();
                return(result.ToString());
            }
            catch (Exception ex)
            {
                return(ex.Message.ToString());
            }
        }
        public void AddLabels([FromBody] LabelsModel newLabel)
        {
            var label = new LabelsModel()
            {
                UserId = newLabel.UserId,
                Labels = newLabel.Labels
            };
            int result = 0;

            try
            {
                this.context.labels.Add(label);
                result = this.context.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
 public void AddLabels([FromBody] LabelsModel newLabel)
 {
     Notes.AddLabels(newLabel);
 }
 public void AddLabels([FromBody] LabelsModel newLabel)
 {
     throw new NotImplementedException();
 }