internal Result SuspendCompany(string externalId, SuspendCustomerParams data) { var loggerManager = new LoggerManager(); var operationGuid = Guid.NewGuid().ToString(); try { loggerManager.InsertLogoRecord(nameof(SuspendCompany), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data)); var orderDemandManager = new OrderDemandManager(); var suspendCompany = new SuspendCompanyData { ExternalId = externalId, OrderDemandGuid = operationGuid }; var validator = new CompanyValidator(); var valResults = validator.Validate(suspendCompany); var validationSucceeded = valResults.IsValid; if (!validationSucceeded) { var failures = valResults.Errors; var message = failures.Aggregate(string.Empty, (current, failure) => current + (failure.ErrorMessage + "<br />")); return(new Result { IsCompleted = false, Success = false, Message = message }); } orderDemandManager.SaveOrderDemand(null, operationGuid, 0, (int)ProvisionType.SuspendCustomer, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(suspendCompany), data.TransactionId); return(new Result { IsCompleted = false, Success = true }); } catch (Exception ex) { loggerManager.InsertLogoRecord(nameof(SuspendCompany), 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> SuspendCompanyAsync(string externalId, SuspendCustomerParams data) { try { var company = await _dataService.CompanyService.ExternalGetAsync(externalId); company.IsSuspended = true; _dataService.CompanyService.Update(company); await _dataService.SaveChangesAsync(); return(await _trendMicroManager.SuspendSubscriptionAsync(externalId)); } catch (Exception ex) { await _dataService.LogDataService.InsertLogoRecordAsync(nameof(SuspendCompanyAsync), nameof(Enums.LogLevel.Error), ex.Message, data.TransactionId, JsonConvert.SerializeObject(data)); return(new Result(false, ex.Message)); } }