Skip to content

Commit

Permalink
1802 task create an aws thing type (#2041)
Browse files Browse the repository at this point in the history
* create Thing Type table

* PostgreSQL DB migration

* Model + Repo + Service Think Type

* Remove Gneric Thing Type

* Test API Done

* Testing ThingType Service (DONE)

* Create Thing Type Controller tested

* some changes in the Cloud Provider

* Add Thing Type Button OK

* Adapt CreateDeviceModelTests with Azure cloud Provider

* #1802 DONE without adding Migration Files

* #1802 DONE with Migration Files Added

* #1802 Correct COnflict Problem

* #1802 PG Migration new class

* create Thing Type table

* PostgreSQL DB migration

* Model + Repo + Service Think Type

* Remove Gneric Thing Type

* Test API Done

* Testing ThingType Service (DONE)

* Create Thing Type Controller tested

* some changes in the Cloud Provider

* Add Thing Type Button OK

* Adapt CreateDeviceModelTests with Azure cloud Provider

* #1802 DONE without adding Migration Files

* correcting Migration Pblm

* correcting conflicts & bugs in Migration files

* Update AWSImageManager

* Fix formatting

* Fix Build Problems

* Fixes on the PR

* change tag dictionary to tag DTO

* Add Copyright CGI

* remove unsused variables

* Using AWS ThingTypeID for my DB

* handle image in Thing type creation

* handle Thing Type image

* uploading avatar in Thing Type (DONE)

* adding test for InsertAndGetIdAsync function

* adding some tests for test cov
  • Loading branch information
ssgueye2 authored May 4, 2023
1 parent e0147af commit 449e91c
Show file tree
Hide file tree
Showing 51 changed files with 2,383 additions and 113 deletions.
1 change: 1 addition & 0 deletions src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[assembly: System.CLSCompliant(false)]

[assembly: InternalsVisibleTo("AzureIoTHub.Portal.Shared")]
[assembly: InternalsVisibleTo("AzureIoTHub.Portal.Infrastructure")]
[assembly: InternalsVisibleTo("AzureIoTHub.Portal.Server")]
[assembly: InternalsVisibleTo("AzureIoTHub.Portal.Client")]
[assembly: InternalsVisibleTo("AzureIoTHub.Portal.Tests.Unit")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AWSSDK.IoT" Version="3.7.107.5" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.8.1" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.38.2" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.2" />
Expand Down
51 changes: 51 additions & 0 deletions src/AzureIoTHub.Portal.Application/Mappers/AWS/ThingTypeProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Application.Mappers.AWS
{
using AutoMapper;
using AzureIoTHub.Portal.Domain.Entities.AWS;
using AzureIoTHub.Portal.Models.v10.AWS;
using Amazon.IoT.Model;
public class ThingTypeProfile : Profile
{
public ThingTypeProfile()
{
_ = CreateMap<ThingTypeDto, ThingType>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.ThingTypeID))
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.ThingTypeName))
.ForMember(dest => dest.Description, opts => opts.MapFrom(src => src.ThingTypeDescription))
.ForMember(dest => dest.ThingTypeSearchableAttributes, opts => opts.MapFrom(src => src.ThingTypeSearchableAttDtos.Select(pair => new ThingTypeSearchableAtt
{
Name = pair.Name
})))
.ForMember(dest => dest.Tags, opts => opts.MapFrom(src => src.Tags.Select(pair => new ThingTypeTag
{
Key = pair.Key,
Value = pair.Value
})));

_ = CreateMap<ThingType, ThingTypeDto>()
.ForMember(dest => dest.ThingTypeID, opts => opts.MapFrom(src => src.Id))
.ForMember(dest => dest.ThingTypeName, opts => opts.MapFrom(src => src.Name))
.ForMember(dest => dest.ThingTypeDescription, opts => opts.MapFrom(src => src.Description))
.ForMember(dest => dest.Tags, opts => opts.MapFrom(src => src.Tags != null ? src.Tags.ToList() : null))
.ForMember(dest => dest.ThingTypeSearchableAttDtos, opts => opts.MapFrom(
src => src.ThingTypeSearchableAttributes != null ? src.ThingTypeSearchableAttributes.ToList() : null));

_ = CreateMap<ThingTypeDto, CreateThingTypeRequest>()
.ForMember(dest => dest.ThingTypeName, opts => opts.MapFrom(src => src.ThingTypeName))
.ForMember(dest => dest.ThingTypeProperties, opts => opts.MapFrom(src => new ThingTypeProperties
{
ThingTypeDescription = src.ThingTypeDescription,
SearchableAttributes = src.ThingTypeSearchableAttDtos.Select(pair => pair.Name).ToList() ?? new List<string>()
}))
.ForMember(dest => dest.Tags, opts => opts.MapFrom(src => src.Tags.Select(pair => new Tag
{
Key = pair.Key,
Value = pair.Value
}).ToList() ?? new List<Tag>()));

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Application.Mappers.AWS
{
using AutoMapper;
using AzureIoTHub.Portal.Domain.Entities.AWS;
using AzureIoTHub.Portal.Models.v10.AWS;

public class ThingTypeSearchableAttProfile : Profile
{
public ThingTypeSearchableAttProfile()
{
_ = CreateMap<ThingTypeSearchableAtt, ThingTypeSearchableAttDto>()
.ForMember(dest => dest.Name, opts => opts.MapFrom(src => src.Name))
.ReverseMap();

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Application.Services.AWS
{
using AzureIoTHub.Portal.Models.v10.AWS;
using Microsoft.AspNetCore.Http;

public interface IThingTypeService
{
//Create a thing type
Task<string> CreateThingType(ThingTypeDto thingType);

Task<string> GetThingTypeAvatar(string thingTypeId);

Task<string> UpdateThingTypeAvatar(string thingTypeId, IFormFile file);

Task DeleteThingTypeAvatar(string thingTypeId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
<ItemGroup>
<ProjectReference Include="..\AzureIoTHub.Portal.Shared\AzureIoTHub.Portal.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Components\AWS\" />
</ItemGroup>

</Project>
Loading

0 comments on commit 449e91c

Please sign in to comment.