Selaa lähdekoodia

Modified Placeholder

master
Kobus 5 vuotta sitten
vanhempi
commit
2778a52349

+ 10
- 0
UnivateProperties_API/Containers/Communication/PlaceHolderDto.cs Näytä tiedosto

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 Näytä tiedosto

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
     public class TemplateDto
6
     public class TemplateDto
4
     {
7
     {
6
         public string Name { get; set; }
9
         public string Name { get; set; }
7
         public string Subject { get; set; }
10
         public string Subject { get; set; }
8
         public string Body { get; set; }
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 Näytä tiedosto

1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
1
+using Microsoft.AspNetCore.Mvc;
5
 using System.Transactions;
2
 using System.Transactions;
6
-using Microsoft.AspNetCore.Http;
7
-using Microsoft.AspNetCore.Mvc;
8
 using UnivateProperties_API.Model.Communication;
3
 using UnivateProperties_API.Model.Communication;
9
 using UnivateProperties_API.Repository;
4
 using UnivateProperties_API.Repository;
5
+using UnivateProperties_API.Repository.Communication;
10
 
6
 
11
 namespace UnivateProperties_API.Controllers.Communication
7
 namespace UnivateProperties_API.Controllers.Communication
12
 {
8
 {
28
             return new OkObjectResult(items);
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
         [HttpGet("{id}")]
34
         [HttpGet("{id}")]
32
         public IActionResult Get(int id)
35
         public IActionResult Get(int id)
33
         {
36
         {

+ 3
- 1
UnivateProperties_API/Model/Communication/PlaceHolder.cs Näytä tiedosto

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

+ 18
- 1
UnivateProperties_API/Repository/Communication/TemplateRepository.cs Näytä tiedosto

114
                     Id = item.Id,
114
                     Id = item.Id,
115
                     Name = item.Name,
115
                     Name = item.Name,
116
                     Subject = item.Subject,
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
             return list;
137
             return list;

Loading…
Peruuta
Tallenna