internal Result RemoveAsset(string customerId, string assetId, RemoveAssetParams data) { var loggerManager = new LoggerManager(); var operationGuid = Guid.NewGuid().ToString(); try { loggerManager.InsertLogoRecord(nameof(RemoveAsset), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data)); var customerManager = new CustomerManager(); var customer = customerManager.GetCompanyByExternalId(customerId); var user = customerManager.GetCompanyFirstAdminByExternalId(customerId); var diskSpace = customerManager.GetDiskSpaceByAssetGroupId(assetId); var orderDemandManager = new OrderDemandManager(); var addAsset = new DeleteDiskSpaceData { OrderDemandGuid = operationGuid, CompanyId = customer.CompanyId, UserId = user.UserId, DiskSpaceId = diskSpace.DiskSpaceID }; orderDemandManager.SaveOrderDemand(null, operationGuid, 0, (int)ProvisionType.DeleteDiskSpace, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(addAsset), data.TransactionId); return(new Result { IsCompleted = false, Success = true }); } catch (Exception ex) { loggerManager.InsertLogoRecord(nameof(RemoveAsset), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, JsonConvert.SerializeObject(data)); return(new Result { IsCompleted = true, Success = false, Message = ex.Message }); } }
public async Task <Result> RemoveAssetAsync(string customerId, string assetId, RemoveAssetParams data) { try { var customer = await _dataService.CompanyService.ExternalGetAsync(customerId); var user = await _dataService.UserService.ExternalGetAsync(customerId); var role = await _dataService.RolesService.GetAsync((int)Role.Admin); var userRole = await _dataService.UserRoleService.GetByUserIdAndRoleAsync(user.Id, role.Id); var ret = await _trendMicroManager.SuspendSubscriptionAsync(customerId); _dataService.UserRoleService.Delete(userRole); await _dataService.SaveChangesAsync(); return(ret); } catch (Exception ex) { await _dataService.LogDataService.InsertLogoRecordAsync(nameof(RemoveAssetAsync), nameof(Enums.LogLevel.Error), ex.Message, data.TransactionId, JsonConvert.SerializeObject(data)); return(new Result(false, ex.Message)); } }