…lines 1–43 unchanged (43 lines)
44
45 protected override CustomFormatResource GetResourceById(int id)
46 {
47 return _formatService.GetById(id).ToResource(true);
48 }
49
50 [HttpGet]
51 [Produces("application/json")]
52 public List<CustomFormatResource> GetAll()
53 {
54 return _formatService.All().ToResource(true);
55 }
56
57 [RestPostById]
58 [Consumes("application/json")]
59 public ActionResult<CustomFormatResource> Create([FromBody] CustomFormatResource customFormatResource)
60 {
61 var model = customFormatResource.ToModel(_specifications);
…lines 62–74 unchanged (13 lines)
75
76 _formatService.Update(model);
77
78 return Accepted(model.Id);
79 }
80
81 [HttpPut("bulk")]
82 [Consumes("application/json")]
83 [Produces("application/json")]
84 public virtual ActionResult<CustomFormatResource> Update([FromBody] CustomFormatBulkResource resource)
85 {
86 if (!resource.Ids.Any())
87 {
88 throw new BadRequestException("ids must be provided");
89 }
90
91 var customFormats = resource.Ids.Select(id => _formatService.GetById(id)).ToList();
92
93 customFormats.ForEach(existing =>
94 {
95 existing.IncludeCustomFormatWhenRenaming = resource.IncludeCustomFormatWhenRenaming ?? existing.IncludeCustomFormatWhenRenaming;
96 });
97
98 _formatService.Update(customFormats);
99
100 return Accepted(customFormats.ConvertAll(cf => cf.ToResource(true)));
101 }
102
103 [RestDeleteById]
104 public void DeleteFormat(int id)
105 {
106 _formatService.Delete(id);
107 }
108
109 [HttpDelete("bulk")]
110 [Consumes("application/json")]
111 public virtual object DeleteFormats([FromBody] CustomFormatBulkResource resource)
112 {
113 _formatService.Delete(resource.Ids.ToList());
114
115 return new { };
116 }
117
118 [HttpGet("schema")]
119 public object GetTemplates()
120 {
121 var schema = _specifications.OrderBy(x => x.Order).Select(x => x.ToSchema()).ToList();
122
123 var presets = GetPresets().ToList();
124
125 foreach (var item in schema)
126 {
127 item.Presets = presets.Where(x => x.GetType().Name == item.Implementation).Select(x => x.ToSchema()).ToList();
128 }
129
…lines 130–202 unchanged (73 lines)