public async Task <Result> RemoveProductAsync(string customerId, string userId, string productId, RemoveProductParams data) { try { var role = await _dataService.RolesService.ExternalGetAsync(productId); var user = await _dataService.UserService.ExternalGetAsync(userId); return(await _dataService.UserRoleService.RemoveUserRole(user.Id, role.Id)); } catch (Exception ex) { await _dataService.LogDataService.InsertLogoRecordAsync(nameof(RemoveProductAsync), nameof(Enums.LogLevel.Error), ex.Message, data.TransactionId, JsonConvert.SerializeObject(data)); return(new Result(false, ex.Message)); } }
internal Result RemoveProduct(string customerId, string userId, string productId, RemoveProductParams data) { var loggerManager = new LoggerManager(); var operationGuid = Guid.NewGuid().ToString(); try { loggerManager.InsertLogoRecord(nameof(RemoveProduct), nameof(LogLevel.Info), null, data.TransactionId, JsonConvert.SerializeObject(data)); var orderDemandManager = new OrderDemandManager(); var removeProduct = new RemoveProductData { ExternalId = userId, OrderDemandGuid = operationGuid, ExternalProcudtId = productId }; var validator = new RemoveProductValidator(); var valResults = validator.Validate(removeProduct); 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.RemoveProduct, (int)OrderDemandStates.Created, (int)OrderDemandType.Integrated, JsonConvert.SerializeObject(removeProduct), data.TransactionId); return(new Result { IsCompleted = false, Success = true }); } catch (Exception ex) { loggerManager.InsertLogoRecord(nameof(RemoveProduct), nameof(LogLevel.Error), ex.Message + " " + ex.StackTrace, operationGuid, JsonConvert.SerializeObject(data)); return(new Result { IsCompleted = true, Success = false, Message = ex.Message }); } }