Escali License control 1
MainSegmentViewModel.cs
Gå til dokumentasjonen til denne filen.
1using AutoMapper;
2using Castle.Core.Internal;
8
10{
12 {
14 public List<MainSegmentClientModel>? MainSegments { get; private set; }
15
17 {
19 _mapper = mapper;
20 }
21 public async Task GetMainSegments()
22 {
23 var products = await _mainSegmentService.GetAllMainSegments();
24 UpdateMainSegments(_mapper.Map<List<MainSegmentClientModel>>(products));
25 }
26
27 public async Task<MainSegmentClientModel> CreateMainSegment(MainSegmentClientModel mainSegmentView)
28 {
29 var mapped = _mapper.Map<MainSegment>(mainSegmentView);
30 var res = await _mainSegmentService.AddMainSegment(mapped);
31 return _mapper.Map<MainSegmentClientModel>(res);
32 }
33
34 private void UpdateMainSegments(List<MainSegmentClientModel> mainSegments)
35 {
36 MainSegments = mainSegments;
38 }
39
40 }
41}
var context
Definition: Program.cs:49
async Task< MainSegmentClientModel > CreateMainSegment(MainSegmentClientModel mainSegmentView)
void UpdateMainSegments(List< MainSegmentClientModel > mainSegments)
MainSegmentService class inserts and updates MainSegment in the Database
async Task< List< MainSegment > > GetAllMainSegments()
Read all Main Segements from database
async Task< MainSegment > AddMainSegment(MainSegment mainSegment)
Adds a Main Segement to the database