Fix fromdto methods + misc
This commit is contained in:
parent
b5396643ce
commit
b3b6a5d6fc
@ -76,8 +76,7 @@ namespace ManagerService.Controllers
|
||||
throw new ArgumentNullException("Application instance param is null");
|
||||
|
||||
// Todo add some verification ?
|
||||
ApplicationInstance applicationInstance = new ApplicationInstance();
|
||||
applicationInstance.FromDTO(newApplicationInstanceDTO);
|
||||
ApplicationInstance applicationInstance = new ApplicationInstance().FromDTO(newApplicationInstanceDTO);
|
||||
applicationInstance.Id = idService.GenerateHexId();
|
||||
|
||||
_myInfoMateDbContext.ApplicationInstances.Add(applicationInstance);
|
||||
@ -121,7 +120,7 @@ namespace ManagerService.Controllers
|
||||
if (applicationInstance == null)
|
||||
throw new KeyNotFoundException("application instance does not exist");
|
||||
|
||||
applicationInstance.FromDTO(updatedApplicationInstanceDTO);
|
||||
applicationInstance = applicationInstance.FromDTO(updatedApplicationInstanceDTO);
|
||||
_myInfoMateDbContext.SaveChanges();
|
||||
|
||||
return new OkObjectResult(applicationInstance.ToDTO());
|
||||
@ -183,6 +182,28 @@ namespace ManagerService.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all application Link
|
||||
/// </summary>
|
||||
/// <param name="applicationInstanceId">application instance id</param>
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(typeof(List<AppConfigurationLinkDTO>), 200)]
|
||||
[ProducesResponseType(typeof(string), 500)]
|
||||
[HttpGet("{applicationInstanceId}/application-link")]
|
||||
public ObjectResult GetAllApplicationLinkFromApplicationInstance([FromQuery] string applicationInstanceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<AppConfigurationLink> appConfigurationLinks = _myInfoMateDbContext.AppConfigurationLinks.Where(acl => acl.ApplicationInstanceId == applicationInstanceId).ToList();
|
||||
|
||||
return new OkObjectResult(appConfigurationLinks.Select(acl => acl.ToDTO()).OrderBy(acl => acl.order));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ObjectResult(ex.Message) { StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new application Link to specified application instance
|
||||
/// </summary>
|
||||
@ -214,9 +235,8 @@ namespace ManagerService.Controllers
|
||||
throw new KeyNotFoundException("This configuration was not found");
|
||||
|
||||
// Todo add some verification ?
|
||||
AppConfigurationLink appConfigurationLink = new AppConfigurationLink();
|
||||
AppConfigurationLink appConfigurationLink = new AppConfigurationLink().FromDTO(appConfigurationLinkDTO);
|
||||
appConfigurationLink.Id = idService.GenerateHexId();
|
||||
appConfigurationLink.FromDTO(appConfigurationLinkDTO);
|
||||
|
||||
_myInfoMateDbContext.AppConfigurationLinks.Add(appConfigurationLink);
|
||||
_myInfoMateDbContext.SaveChanges();
|
||||
@ -237,6 +257,46 @@ namespace ManagerService.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an app configuration link
|
||||
/// </summary>
|
||||
/// <param name="appConfigurationLinkDTO">App configuration link to update</param>
|
||||
[ProducesResponseType(typeof(AppConfigurationLinkDTO), 200)]
|
||||
[ProducesResponseType(typeof(string), 400)]
|
||||
[ProducesResponseType(typeof(string), 404)]
|
||||
[ProducesResponseType(typeof(string), 500)]
|
||||
[HttpPut("application-link")]
|
||||
public ObjectResult UpdateApplicationLink([FromBody] AppConfigurationLinkDTO appConfigurationLinkDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (appConfigurationLinkDTO == null)
|
||||
throw new ArgumentNullException("appConfigurationLink param is null");
|
||||
|
||||
AppConfigurationLink appConfigurationLink = _myInfoMateDbContext.AppConfigurationLinks.FirstOrDefault(acl => acl.Id == appConfigurationLinkDTO.id);
|
||||
|
||||
if (appConfigurationLink == null)
|
||||
throw new KeyNotFoundException("appConfigurationLink does not exist");
|
||||
|
||||
appConfigurationLink = appConfigurationLink.FromDTO(appConfigurationLinkDTO);
|
||||
_myInfoMateDbContext.SaveChanges();
|
||||
|
||||
return new OkObjectResult(appConfigurationLink.ToDTO());
|
||||
}
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
return new BadRequestObjectResult(ex.Message) { };
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
return new NotFoundObjectResult(ex.Message) { };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ObjectResult(ex.Message) { StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove configuration from instance
|
||||
/// </summary>
|
||||
|
||||
@ -1094,5 +1094,25 @@ namespace ManagerService.Controllers
|
||||
{
|
||||
return new ObjectResult("WeatherDTO") { StatusCode = 200 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useless, just to generate dto code
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(SectionEventDTO), 200)]
|
||||
[HttpGet("SectionEventDTO")]
|
||||
public ObjectResult GetSectionEventDTO()
|
||||
{
|
||||
return new ObjectResult("SectionEventDTO") { StatusCode = 200 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Useless, just to generate dto code
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(GuidedPathDTO), 200)]
|
||||
[HttpGet("GuidedPathDTO")]
|
||||
public ObjectResult GetGuidedPathDTO()
|
||||
{
|
||||
return new ObjectResult("GuidedPathDTO") { StatusCode = 200 };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace ManagerService.Controllers
|
||||
[ProducesResponseType(typeof(List<ProgrammeBlock>), 200)]
|
||||
[ProducesResponseType(typeof(string), 404)]
|
||||
[ProducesResponseType(typeof(string), 500)]
|
||||
[HttpGet("{sectionId}/programmes")]
|
||||
[HttpGet("{sectionEventId}/programmes")]
|
||||
public ObjectResult GetAllProgrammeBlockFromSection(string sectionEventId)
|
||||
{
|
||||
try
|
||||
|
||||
@ -50,15 +50,12 @@ namespace ManagerService.Data
|
||||
|
||||
public AppConfigurationLink FromDTO(AppConfigurationLinkDTO appConfigurationLinkDTO)
|
||||
{
|
||||
return new AppConfigurationLink()
|
||||
{
|
||||
Id = appConfigurationLinkDTO.id,
|
||||
ConfigurationId = appConfigurationLinkDTO.configurationId,
|
||||
ApplicationInstanceId = appConfigurationLinkDTO.applicationInstanceId,
|
||||
Order = appConfigurationLinkDTO.order,
|
||||
IsActive = appConfigurationLinkDTO.isActive,
|
||||
WeightMasonryGrid = appConfigurationLinkDTO?.weightMasonryGrid,
|
||||
};
|
||||
ConfigurationId = appConfigurationLinkDTO.configurationId;
|
||||
ApplicationInstanceId = appConfigurationLinkDTO.applicationInstanceId;
|
||||
Order = appConfigurationLinkDTO.order;
|
||||
IsActive = appConfigurationLinkDTO.isActive;
|
||||
WeightMasonryGrid = appConfigurationLinkDTO?.weightMasonryGrid;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -77,27 +77,25 @@ namespace ManagerService.Data
|
||||
};
|
||||
}
|
||||
|
||||
public ApplicationInstance FromDTO(ApplicationInstanceDTO applicationInstanceDTO)
|
||||
public ApplicationInstance FromDTO(ApplicationInstanceDTO dto)
|
||||
{
|
||||
return new ApplicationInstance()
|
||||
{
|
||||
Id = applicationInstanceDTO.id,
|
||||
InstanceId = applicationInstanceDTO.instanceId,
|
||||
AppType = applicationInstanceDTO.appType,
|
||||
MainImageId = applicationInstanceDTO.mainImageId,
|
||||
MainImageUrl = applicationInstanceDTO.mainImageUrl,
|
||||
LoaderImageId = applicationInstanceDTO.loaderImageId,
|
||||
LoaderImageUrl = applicationInstanceDTO.loaderImageUrl,
|
||||
IsDate = applicationInstanceDTO.isDate,
|
||||
IsHour = applicationInstanceDTO.isHour,
|
||||
PrimaryColor = applicationInstanceDTO.primaryColor,
|
||||
SecondaryColor = applicationInstanceDTO.secondaryColor,
|
||||
RoundedValue = applicationInstanceDTO.roundedValue,
|
||||
ScreenPercentageSectionsMainPage = applicationInstanceDTO.screenPercentageSectionsMainPage,
|
||||
IsSectionImageBackground = applicationInstanceDTO.isSectionImageBackground,
|
||||
Languages = applicationInstanceDTO.languages,
|
||||
Configurations = applicationInstanceDTO.configurations,
|
||||
};
|
||||
InstanceId = dto.instanceId;
|
||||
AppType = dto.appType;
|
||||
MainImageId = dto.mainImageId;
|
||||
MainImageUrl = dto.mainImageUrl;
|
||||
LoaderImageId = dto.loaderImageId;
|
||||
LoaderImageUrl = dto.loaderImageUrl;
|
||||
IsDate = dto.isDate;
|
||||
IsHour = dto.isHour;
|
||||
PrimaryColor = dto.primaryColor;
|
||||
SecondaryColor = dto.secondaryColor;
|
||||
RoundedValue = dto.roundedValue;
|
||||
ScreenPercentageSectionsMainPage = dto.screenPercentageSectionsMainPage;
|
||||
IsSectionImageBackground = dto.isSectionImageBackground;
|
||||
Languages = dto.languages;
|
||||
Configurations = dto.configurations;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -111,23 +111,20 @@ namespace ManagerService.Data
|
||||
|
||||
public Device FromDTO(DeviceDetailDTO deviceDetailDTO)
|
||||
{
|
||||
return new Device()
|
||||
{
|
||||
Id = deviceDetailDTO.id,
|
||||
Name = deviceDetailDTO.name,
|
||||
DateCreation = deviceDetailDTO.dateCreation != null ? deviceDetailDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(),
|
||||
Identifier = deviceDetailDTO.identifier,
|
||||
IpAddressWLAN = deviceDetailDTO.ipAddressWLAN,
|
||||
IpAddressETH = deviceDetailDTO.ipAddressETH,
|
||||
Connected = deviceDetailDTO.connected,
|
||||
ConfigurationId = deviceDetailDTO.configurationId,
|
||||
ConnectionLevel = deviceDetailDTO.connectionLevel,
|
||||
LastConnectionLevel = deviceDetailDTO.lastConnectionLevel,
|
||||
BatteryLevel = deviceDetailDTO.batteryLevel,
|
||||
LastBatteryLevel = deviceDetailDTO.lastBatteryLevel,
|
||||
DateUpdate = deviceDetailDTO.dateUpdate != null ? deviceDetailDTO.dateUpdate.Value : DateTime.Now.ToUniversalTime(),
|
||||
InstanceId = deviceDetailDTO.instanceId
|
||||
};
|
||||
Name = deviceDetailDTO.name;
|
||||
DateCreation = deviceDetailDTO.dateCreation != null ? deviceDetailDTO.dateCreation.Value : DateTime.Now.ToUniversalTime();
|
||||
Identifier = deviceDetailDTO.identifier;
|
||||
IpAddressWLAN = deviceDetailDTO.ipAddressWLAN;
|
||||
IpAddressETH = deviceDetailDTO.ipAddressETH;
|
||||
Connected = deviceDetailDTO.connected;
|
||||
ConfigurationId = deviceDetailDTO.configurationId;
|
||||
ConnectionLevel = deviceDetailDTO.connectionLevel;
|
||||
LastConnectionLevel = deviceDetailDTO.lastConnectionLevel;
|
||||
BatteryLevel = deviceDetailDTO.batteryLevel;
|
||||
LastBatteryLevel = deviceDetailDTO.lastBatteryLevel;
|
||||
DateUpdate = deviceDetailDTO.dateUpdate != null ? deviceDetailDTO.dateUpdate.Value : DateTime.Now.ToUniversalTime();
|
||||
InstanceId = deviceDetailDTO.instanceId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,18 +49,15 @@ namespace ManagerService.Data
|
||||
|
||||
public Instance FromDTO(InstanceDTO instanceDTO)
|
||||
{
|
||||
return new Instance()
|
||||
{
|
||||
Id = instanceDTO.id,
|
||||
Name = instanceDTO.name,
|
||||
DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(),
|
||||
PinCode = instanceDTO.pinCode,
|
||||
IsPushNotification = instanceDTO.isPushNotification,
|
||||
IsStatistic = instanceDTO.isStatistic,
|
||||
IsMobile = instanceDTO.isMobile,
|
||||
IsTablet = instanceDTO.isTablet,
|
||||
IsVR = instanceDTO.isVR
|
||||
};
|
||||
Name = instanceDTO.name;
|
||||
DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime();
|
||||
PinCode = instanceDTO.pinCode;
|
||||
IsPushNotification = instanceDTO.isPushNotification;
|
||||
IsStatistic = instanceDTO.isStatistic;
|
||||
IsMobile = instanceDTO.isMobile;
|
||||
IsTablet = instanceDTO.isTablet;
|
||||
IsVR = instanceDTO.isVR;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -96,17 +96,14 @@ namespace ManagerService.Data.SubSection
|
||||
|
||||
public EventAgenda FromDTO(EventAgendaDTO dto)
|
||||
{
|
||||
return new EventAgenda
|
||||
{
|
||||
Id = dto.id,
|
||||
Label = dto.label,
|
||||
Description = dto.description,
|
||||
Type = dto.type,
|
||||
DateAdded = dto.dateAdded,
|
||||
DateFrom = dto.dateFrom,
|
||||
DateTo = dto.dateTo,
|
||||
Website = dto.website,
|
||||
ResourceId = dto.resourceId,
|
||||
Label = dto.label;
|
||||
Description = dto.description;
|
||||
Type = dto.type;
|
||||
DateAdded = dto.dateAdded;
|
||||
DateFrom = dto.dateFrom;
|
||||
DateTo = dto.dateTo;
|
||||
Website = dto.website;
|
||||
ResourceId = dto.resourceId;
|
||||
//Resource = dto.Resource != null ? Resource.From(dto.Resource) : null,
|
||||
Address = dto.address != null ? new EventAddress
|
||||
{
|
||||
@ -120,11 +117,11 @@ namespace ManagerService.Data.SubSection
|
||||
Geometry = dto.address.geometry != null ? dto.address.geometry.FromDto() : null,
|
||||
PolyColor = dto.address.polyColor,
|
||||
Zoom = dto.address.zoom
|
||||
} : null,
|
||||
Phone = dto.phone,
|
||||
Email = dto.email,
|
||||
SectionAgendaId = dto.sectionAgendaId
|
||||
};
|
||||
} : null;
|
||||
Phone = dto.phone;
|
||||
Email = dto.email;
|
||||
SectionAgendaId = dto.sectionAgendaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -48,15 +48,12 @@ namespace ManagerService.Data.SubSection
|
||||
|
||||
public ProgrammeBlock FromDTO(ProgrammeBlockDTO dto)
|
||||
{
|
||||
return new ProgrammeBlock
|
||||
{
|
||||
Id = dto.id,
|
||||
Title = dto.title,
|
||||
Description = dto.description,
|
||||
StartTime = dto.startTime,
|
||||
EndTime = dto.endTime,
|
||||
Title = dto.title;
|
||||
Description = dto.description;
|
||||
StartTime = dto.startTime;
|
||||
EndTime = dto.endTime;
|
||||
//MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@ -94,18 +91,15 @@ namespace ManagerService.Data.SubSection
|
||||
|
||||
public MapAnnotation FromDTO(MapAnnotationDTO dto)
|
||||
{
|
||||
return new MapAnnotation
|
||||
{
|
||||
Id = dto.id,
|
||||
Type = dto.type,
|
||||
Label = dto.label,
|
||||
GeometryType = dto.geometryType,
|
||||
Geometry = dto.geometry.FromDto(),
|
||||
PolyColor = dto.polyColor,
|
||||
Icon = dto.icon,
|
||||
IconResourceId = dto.iconResourceId,
|
||||
Type = dto.type;
|
||||
Label = dto.label;
|
||||
GeometryType = dto.geometryType;
|
||||
Geometry = dto.geometry.FromDto();
|
||||
PolyColor = dto.polyColor;
|
||||
Icon = dto.icon;
|
||||
IconResourceId = dto.iconResourceId;
|
||||
//IconResource = dto.IconResource?.ToModel()
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace ManagerService.Data.SubSection
|
||||
{
|
||||
@ -205,20 +204,17 @@ namespace ManagerService.Data.SubSection
|
||||
{
|
||||
if (dto == null) return null;
|
||||
|
||||
return new GuidedPath
|
||||
{
|
||||
Id = dto.id,
|
||||
InstanceId = dto.instanceId,
|
||||
Title = dto.title ?? new List<TranslationDTO>(),
|
||||
Description = dto.description ?? new List<TranslationDTO>(),
|
||||
SectionMapId = dto.sectionMapId,
|
||||
SectionEventId = dto.sectionEventId,
|
||||
IsLinear = dto.isLinear,
|
||||
RequireSuccessToAdvance = dto.requireSuccessToAdvance,
|
||||
HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete,
|
||||
Order = dto.order,
|
||||
InstanceId = dto.instanceId;
|
||||
Title = dto.title ?? new List<TranslationDTO>();
|
||||
Description = dto.description ?? new List<TranslationDTO>();
|
||||
SectionMapId = dto.sectionMapId;
|
||||
SectionEventId = dto.sectionEventId;
|
||||
IsLinear = dto.isLinear;
|
||||
RequireSuccessToAdvance = dto.requireSuccessToAdvance;
|
||||
HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete;
|
||||
Order = dto.order;
|
||||
//Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List<GuidedStep>() // Other method
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@ -299,24 +295,21 @@ namespace ManagerService.Data.SubSection
|
||||
{
|
||||
if (dto == null) return null;
|
||||
|
||||
return new GuidedStep
|
||||
{
|
||||
Id = dto.id,
|
||||
GuidedPathId = dto.guidedPathId,
|
||||
Title = dto.title ?? new List<TranslationDTO>(),
|
||||
Description = dto.description ?? new List<TranslationDTO>(),
|
||||
Geometry = dto.geometry.FromDto(),
|
||||
ZoneRadiusMeters = dto.zoneRadiusMeters,
|
||||
ImageUrl = dto.imageUrl,
|
||||
TriggerGeoPointId = dto.triggerGeoPointId,
|
||||
IsHiddenInitially = dto.isHiddenInitially,
|
||||
IsStepTimer = dto.isStepTimer,
|
||||
IsStepLocked = dto.isStepLocked,
|
||||
TimerSeconds = dto.timerSeconds,
|
||||
TimerExpiredMessage = dto.timerExpiredMessage ?? new List<TranslationDTO>(),
|
||||
Order = dto.order,
|
||||
QuizQuestions = dto.quizQuestions
|
||||
};
|
||||
GuidedPathId = dto.guidedPathId;
|
||||
Title = dto.title ?? new List<TranslationDTO>();
|
||||
Description = dto.description ?? new List<TranslationDTO>();
|
||||
Geometry = dto.geometry.FromDto();
|
||||
ZoneRadiusMeters = dto.zoneRadiusMeters;
|
||||
ImageUrl = dto.imageUrl;
|
||||
TriggerGeoPointId = dto.triggerGeoPointId;
|
||||
IsHiddenInitially = dto.isHiddenInitially;
|
||||
IsStepTimer = dto.isStepTimer;
|
||||
IsStepLocked = dto.isStepLocked;
|
||||
TimerSeconds = dto.timerSeconds;
|
||||
TimerExpiredMessage = dto.timerExpiredMessage ?? new List<TranslationDTO>();
|
||||
Order = dto.order;
|
||||
QuizQuestions = dto.quizQuestions;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user