public ThingProfile() { CreateMap <Entities.IThing, Model.IThing>() .ForMember(dest => dest.Id, opt => opt.MapFrom(src => ThingIdHelper.Create(src.Fqdn, src.US, true))) ; CreateMap <Model.IThing, Entities.IThing>() .ForMember(dest => dest.Id, opt => opt.Ignore()) .ForMember(dest => dest.Fqdn, opt => opt.MapFrom(src => src.Id != null ? ThingIdHelper.GetFQDN(src.Id) : null)) .ForMember(dest => dest.US, opt => opt.MapFrom(src => src.Id != null ? ThingIdHelper.GetUniqueString(src.Id) : null)) ; CreateMap <Model.BaseThing, Entities.BaseThing>() .IncludeBase <Model.IThing, Entities.IThing>() .ForMember(dest => dest.Id, opt => opt.Ignore()) ; CreateMap <Entities.BaseThing, Model.BaseThing>() .IncludeBase <Entities.IThing, Model.IThing>() ; CreateMap <Entities.RegularThing, Model.RegularThing>() .IncludeBase <Entities.IThing, Model.IThing>() ; CreateMap <Model.RegularThing, Entities.RegularThing>() .IncludeBase <Model.IThing, Entities.IThing>() .ForMember(dest => dest.Id, opt => opt.Ignore()) ; }
private TThingEntity Find(TThingModel value) { if (value == null || value.Id == null) { throw new ArgumentNullException("value", "Thing or Thing Id is null."); } return(Find(ThingIdHelper.GetFQDN(value.Id), ThingIdHelper.GetUniqueString(value.Id))); }
public IActionResult Post([FromBody] AuthenticationRequest value) { // mock, AuthenticationThing is created if not exists if (string.IsNullOrWhiteSpace(value.ThingId)) { value.ThingId = "inventory1.sovelto.fi/Teemu Testaaja"; } var T0 = dbc.AuthenticationThings.SingleOrDefault(t => t.Fqdn == ThingIdHelper.GetFQDN(value.ThingId) && t.US == ThingIdHelper.GetUniqueString(value.ThingId)); if (T0 == null) { T0 = new T2D.Entities.AuthenticationThing { Fqdn = ThingIdHelper.GetFQDN(value.ThingId), US = ThingIdHelper.GetUniqueString(value.ThingId), Title = $"User {ThingIdHelper.GetUniqueString(value.ThingId)}", }; dbc.AuthenticationThings.Add(T0); dbc.SaveChanges(); } //Create SessionEntity var session = new Session { EntryPoint_ThingId = T0.Id, StartTime = DateTime.UtcNow, }; dbc.Sessions.Add(session); dbc.SaveChanges(); var ret = new AuthenticationResponse { Session = session.Id.ToString(), }; return(Ok(ret)); }
private IQueryable <T2D.Entities.BaseThing> Find(string thingId) { return(dbc.Things.Where(t => t.Fqdn == ThingIdHelper.GetFQDN(thingId) && t.US == ThingIdHelper.GetUniqueString(thingId))); }