Ver código fonte

Modified Placeholder

master
Kobus 5 anos atrás
pai
commit
2778a52349

+ 10
- 0
UnivateProperties_API/Containers/Communication/PlaceHolderDto.cs Ver arquivo

@@ -0,0 +1,10 @@
1
+namespace UnivateProperties_API.Containers.Communication
2
+{
3
+    public class PlaceHolderDto
4
+    {
5
+        public string Name { get; set; }
6
+        public string BoundToClass { get; set; }
7
+        public string BoundToClassDisplay { get; set; }
8
+        public string BoundTo { get; set; }
9
+    }
10
+}

+ 5
- 1
UnivateProperties_API/Containers/Communication/TemplateDto.cs Ver arquivo

@@ -1,4 +1,7 @@
1
-namespace UnivateProperties_API.Containers.Communication
1
+using System.Collections.Generic;
2
+using UnivateProperties_API.Model.Communication;
3
+
4
+namespace UnivateProperties_API.Containers.Communication
2 5
 {
3 6
     public class TemplateDto
4 7
     {
@@ -6,5 +9,6 @@
6 9
         public string Name { get; set; }
7 10
         public string Subject { get; set; }
8 11
         public string Body { get; set; }
12
+        public List<PlaceHolderDto> PlaceHolders { get; set; }
9 13
     }
10 14
 }

+ 9
- 6
UnivateProperties_API/Controllers/Communication/TemplateController.cs Ver arquivo

@@ -1,12 +1,8 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
1
+using Microsoft.AspNetCore.Mvc;
5 2
 using System.Transactions;
6
-using Microsoft.AspNetCore.Http;
7
-using Microsoft.AspNetCore.Mvc;
8 3
 using UnivateProperties_API.Model.Communication;
9 4
 using UnivateProperties_API.Repository;
5
+using UnivateProperties_API.Repository.Communication;
10 6
 
11 7
 namespace UnivateProperties_API.Controllers.Communication
12 8
 {
@@ -28,6 +24,13 @@ namespace UnivateProperties_API.Controllers.Communication
28 24
             return new OkObjectResult(items);
29 25
         }
30 26
 
27
+        [HttpGet("getSimple")]
28
+        public IActionResult GetSimple()
29
+        {
30
+            var items = (_Repo as TemplateRepository).GetSimpleAll();
31
+            return new OkObjectResult(items);
32
+        }
33
+
31 34
         [HttpGet("{id}")]
32 35
         public IActionResult Get(int id)
33 36
         {

+ 3
- 1
UnivateProperties_API/Model/Communication/PlaceHolder.cs Ver arquivo

@@ -3,12 +3,14 @@ using System.ComponentModel.DataAnnotations.Schema;
3 3
 
4 4
 namespace UnivateProperties_API.Model.Communication
5 5
 {
6
-    public class PlaceHolder
6
+    public class PlaceHolder : BaseEntity
7 7
     {
8 8
         [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
9 9
         [Key]
10 10
         public int Id { get; set; }
11 11
         public string Name { get; set; }
12
+        public string BoundToClass { get; set; }
13
+        public string BoundToClassDisplay { get; set; }
12 14
         public string BoundTo { get; set; }
13 15
         [ForeignKey("Template")]
14 16
         public int TemplateId { get; set; }

+ 18
- 1
UnivateProperties_API/Repository/Communication/TemplateRepository.cs Ver arquivo

@@ -114,7 +114,24 @@ namespace UnivateProperties_API.Repository.Communication
114 114
                     Id = item.Id,
115 115
                     Name = item.Name,
116 116
                     Subject = item.Subject,
117
-                    Body = item.Body
117
+                    Body = item.Body,
118
+                    PlaceHolders = GetPlaceHolders(item.Id)
119
+                });
120
+            }
121
+            return list;
122
+        }
123
+
124
+        private List<PlaceHolderDto> GetPlaceHolders(int id)
125
+        {
126
+            List<PlaceHolderDto> list = new List<PlaceHolderDto>();
127
+            foreach(var item in _dbContext.PlaceHolders.Where(x => x.TemplateId == id).ToList())
128
+            {
129
+                list.Add(new PlaceHolderDto()
130
+                {
131
+                    Name = item.Name,
132
+                    BoundTo = item.BoundTo,
133
+                    BoundToClass = item.BoundToClass,
134
+                    BoundToClassDisplay = item.BoundToClassDisplay
118 135
                 });
119 136
             }
120 137
             return list;

Carregando…
Cancelar
Salvar