internal Result RemoveUser(string customerId, string externalId, RemoveUserParams data) { var loggerManager = new LoggerManager(); var operationGuid = Guid.NewGuid().ToString(); try { loggerManager.InsertLogoRecord(nameof(RemoveUser), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data)); var orderDemandManager = new OrderDemandManager(); var removeUser = new DeleteUserData { ExternalId = externalId, OrderDemandGuid = operationGuid }; var validator = new RemoveUserValidator(); var valResults = validator.Validate(removeUser); 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.DeleteUser, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(removeUser), data.TransactionId); return(new Result { IsCompleted = false, Success = true }); } catch (Exception ex) { loggerManager.InsertLogoRecord(nameof(RemoveUser), 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> RemoveUserAsync(string customerId, string externalId, RemoveUserParams data) { try { var user = await _dataService.UserService.ExternalGetAsync(externalId); user.IsDeleted = true; _dataService.UserService.Update(user); await _dataService.SaveChangesAsync(); return(new Result(true, null)); } catch (Exception ex) { await _dataService.LogDataService.InsertLogoRecordAsync(nameof(RemoveUserAsync), nameof(Enums.LogLevel.Error), ex.Message, data.TransactionId, JsonConvert.SerializeObject(data)); return(new Result(false, ex.Message)); } }