Пример #1
0
        public static TModel FromConversation <TModel>(Conversation conversation) where
        TModel : ConversationApiModel, new()
        {
            var model = new TModel();

            model.Id       = conversation.Id;
            model.TenantId = conversation.TenantId;
            model.Profiles = conversation.Profiles.Select(x => ProfileApiModel.FromProfile(x)).ToList();
            model.Messages = conversation.Messages.Select(x => MessageApiModel.FromMessage(x)).ToList();
            return(model);
        }
Пример #2
0
        public static TModel FromUser <TModel>(User user) where
        TModel : UserApiModel, new()
        {
            var model = new TModel();

            model.Id       = user.Id;
            model.Name     = user.Name;
            model.Username = user.Username;
            model.Profile  = ProfileApiModel.FromProfile(user.Profile);
            return(model);
        }
        public async Task <SaveAvatarCommand.Response> HandleSaveAvatarCommand(SaveAvatarCommand.Request request, CancellationToken cancellationToken, SaveAvatarCommand.Response response)
        {
            var profile = await _context.Profiles.FindAsync(response.ProfileId);

            await _hubContext.Clients.All.SendAsync("message", new
            {
                Type    = "[Profile] Changed",
                Payload = new { profile = ProfileApiModel.FromProfile(profile) }
            });

            return(response);
        }
        public static TModel FromAccount <TModel>(Account account) where
        TModel : AccountApiModel, new()
        {
            var model = new TModel();

            model.Id = account.Id;

            model.TenantId = account.TenantId;

            model.Name = account.Name;

            model.Firstname = account.Firstname;

            model.Lastname = account.Lastname;

            model.Email = account.Email;

            model.Profiles = account.Profiles.Select(x => ProfileApiModel.FromProfile(x)).ToList();

            return(model);
        }
Пример #5
0
 public async Task <ProfileApiModel> UpdateAsync(string id, [FromBody] ProfileApiModel input)
 {
     return(new ProfileApiModel(await this.storage.UpdateProfileAsync(id, input.ToServiceModel(), input.ETag)));
 }
Пример #6
0
 public async Task <ProfileApiModel> CreateAsync([FromBody] ProfileApiModel input)
 {
     return(new ProfileApiModel(await this.storage.CreateProfileAsync(input.ToServiceModel())));
 }