public static dynamic ToManageSubscriptionsAndLicencesCommand(this Office365UserAssignLicenseViewModel viewModel) { return(new { viewModel.CompanyId, viewModel.CloudPlusProductIdentifier, Users = new List <Office365UserViewModel> { new Office365UserViewModel { UserPrincipalName = viewModel.UserPrincipalName, Password = string.IsNullOrEmpty(viewModel.Password) ? null : viewModel.Password } }, viewModel.UserRoles, MessageType = ManageSubsctiptionAndLicenceCommandType.AssignNewLicence }); }
public async Task <IHttpActionResult> AssignLicense([FromBody] Office365UserAssignLicenseViewModel model) { var office365UserAssignLicense = Office365ServiceConstants.QueueManageSubscriptionsAndLicences; if (string.IsNullOrWhiteSpace(model.CloudPlusProductIdentifier)) { await _messageBroker.GetSendEndpoint(Office365ServiceConstants.QueueOffice365CreateUser) .Send <IOffice365UserCreateCommand>(new { model.CompanyId, model.UserPrincipalName, UsageLocation = "US", model.UserRoles, Password = string.IsNullOrEmpty(model.Password) ? null : model.Password }); } else { await _messageBroker.GetSendEndpoint(office365UserAssignLicense) .Send <IManageSubscriptionsAndLicencesCommand>(model.ToManageSubscriptionsAndLicencesCommand()); } return(Ok()); }